So… you’ve probably heard of discord, a chat and stream app for gamers. Over time it has evolved but it is still there for one main thing: chatting. Nowdays, you can create bots for discord that act as users and put some fun into discord with games, moderation, and trolling. Bots can be coded in many different languages, and it’s pretty common to make one in discord.js or discord.py.
To start, you need to open repl.it and start a new python code. Write
on the first line
but before that, go to the packages section and search discord to install it.
To host the bot, create a new file and name it keep_alive.py. Now type the following into the file
from flask import Flask
now go back to main.py.
Before you start coding, you need to create the actual discord bot. you can do this by going here
and then press the button that says new application in the top right:
Name it whatever you want, but when you’re done, go to the section that says bot
and click it.
You should see a screen like this
Now to bring it to life, press add bot and then press “yes do it”. You can name it and edit the profile picture, but the big part is copying the token
now head back to the main.py file and at the end of it, write the following:
import keep_alive #this should be the name of the file that you created earlier
now head back to the beginning of the file, where you imported discord. There, type
client = discord.Client()
Congrats! You have officially made your discord bot! It doesn’t do anything yet, but one last step before we finish is inviting it to a server.
If you scroll to the bottom of the OATH2 page (the sidebar next to bot), you will see this:
click on “bot” and another panel will appear. On this new panel, click “Administrator” and copy the generated link at the bottom.
go to the link you copied and invite it to a server. I would recommend making a testing server for this.
PERFECT! Your bot is up on a server, but it doesn’t do anything yet 😞. Well, stay tuned for part 2 on how to make commands, send embeds, and more! Go ahead and check the code here
discord.py documentation (the docs)
And check out the second part here!