Customize and deploy your own welcome memebot for your Discord server!
This template repository has all the code you need, with a preconfigured Codespaces development environment, to send a welcome message along with a meme when a user joins your Discord server.
This template repository requires a .env
file to pass variables to your application. The .env
file is used to store data that you want to keep private or hidden like API keys or tokens from external services like Discord.
This template repository has a sample .env file, .env-sample
, that you can rename to .env
or copy and paste the variables in .env-sample
into a new .env
file.
In your .env
file you will find a variable named MEME_URL
where you can add a URL to your favorite meme.
In the src
directory you will find another directory called events
. Open the events
directory and you will find the guildMemberAdd.js
file. You'll notice that we left helpful comments on where you can update the code to your liking.
To add a welcome message, you can update the getWelcomeMessage
function after the content:
keyword.
Maybe you want to use an API service to provide random memes or maybe you don't want to share a meme at all. No matter what route you choose, you should take this Discord bot and make it your own. 😃
We recommend creating a new branch anytime you tinker so you don't have to worry about making mistakes on your main branch. Once your new branch is in a good state, you can merge your changes to your main branch using a pull request. 🚀
Visit https://discord.com/developers/applications to create a new application on Discord. Once there, click the new application
button. After you click on the new application
button, you can then create a new application (Note: That we created a new application called Bot Developer
):
After creating an application you should see the application under My applications
. Open your newly created application by clicking on it.
Select the Bot settings to edit the details. First, click on reset token to generate a new token that you will use in your .env
file. Copy the generated token and set the TOKEN
variable in your .env
file with your newly generated token.
Select the public bot option if you want your bot to be publically available. Select all the Privileged Gateway Intents like PRESENCE INTENT, SERVER MEMBERS INTENT, MESSAGE CONTENT INTENT if your bot needs those intents.(Note: For this application you'll need all of these intents.)
Open the OAuth2
setting and then select URL Generator
.
Select the bot
checkbox under SCOPES
. After, select Send Messages
, Mention Everyone
, and Add Reactions
.
Once you have set your bot permissions copy the generated url below.
Visit the generated url from the previous step and choose the server that you want to add the bot to. Once you've selected the server click continue.
Once the bot is added it will appear on your Discord server in offline mode.
You can now run the code in the repository using the command line by typing the command npm start
.