Discord Welcome Message Bot
import os
import discord
from discord.ext import commands
from abilities import llm_prompt
intents = discord.Intents.all()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
# Global variable to store channel ID
welcome_channel_id = os.getenv('WELCOME_CHANNEL_ID')
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.event
async def on_member_join(member):
if welcome_channel_id:
channel = bot.get_channel(int(welcome_channel_id))
if channel:
# Generate a unique poem for the new member
poem_prompt = f'Write a short welcome poem for a new member named {member.name}.'
Created: | Last Updated:
Introduction to the Discord Welcome Message Bot Template
Welcome to the step-by-step guide on how to use the Discord Welcome Message Bot template on the Lazy platform. This template is designed to help you create a bot that welcomes new members to your Discord server with a unique poem. The bot is easy to set up and requires no coding experience. By following this guide, you'll be able to deploy your own welcome bot in no time.
Clicking Start with this Template
To begin, click on the "Start with this Template" button. This will initialize the template within the Lazy Builder interface, pre-populating the code necessary for your welcome message bot.
Initial Setup: Adding Environment Secrets
Before you can test your bot, you need to set up two environment secrets that the bot requires to function:
- DISCORD_BOT_TOKEN: The token for your Discord bot, which allows it to interact with the Discord API.
- WELCOME_CHANNEL_ID: The ID of the Discord channel where the bot will send welcome messages.
To acquire these, you'll need to create a bot on the Discord Developer Portal and invite it to your server. Here are the steps:
- Go to the Discord Developer Portal and create a new application.
- Within the application, navigate to the "Bot" tab and click "Add Bot".
- Under the bot settings, you'll find the token. Click "Copy" to get your DISCORD_BOT_TOKEN.
- Invite the bot to your server by using the OAuth2 URL generator in the "OAuth2" tab, selecting the appropriate permissions.
- Once the bot is in your server, right-click on the channel you want to use for welcome messages and click "Copy ID" to get your WELCOME_CHANNEL_ID.
After obtaining these values, enter them into the Environment Secrets tab within the Lazy Builder.
Test: Pressing the Test Button
With the environment secrets set, you can now press the "Test" button. This will deploy your application and launch the Lazy CLI. The CLI will prompt you for any required user input.
Entering Input: Filling in User Input
Analyze the code to see if the code requires user input through the CLI. If the code does not prompt for user input, you can omit this section.
Using the App
If the app hosts a frontend experience, this section will guide you through interacting with it. However, since this template is for a Discord bot, there is no frontend interface to discuss.
Integrating the App
Once your bot is running, it will automatically send a welcome poem to new members who join your Discord server. If you need to change the welcome channel, use the provided command within your Discord server:
!set_welcome_channel #channel-name
Replace "#channel-name" with the actual channel you wish to set as the new welcome channel.
That's all there is to it! Your Discord Custom Welcome Message Bot is now set up and ready to greet new members with a poetic touch. Enjoy engaging your community with this unique and personal touch.