This is a continuation of the previous article but can also serve as a general guide on setting up a Discord bot. First, we need to create a Discord bot in the Discord developer console and making a new app. You may customize it however you want, but we are mostly interested in the bot’s token which will be provided upon its creation. When you get that, save it for later. Afterwards, we will need to visit Amazon Web Services (AWS). This is because AWS has the cheapest and most intuitive instance type out of all web service providers. After signing in, we shall go to the EC2 dashboard. The specs should be as follows:
Name: Discord Bot
OS Image: Debian
Instance Type: t2.nano
there are more options, but they don’t need changing. Next, click on the instance in the console and click on the connect button. From there you’ll want to go to the SSH client tab
The tab will provide instruction as to how to connect to it through your window’s console (which can be accessed by typing cmd into your start menu). I cannot show the full screenshot as it contains sensitive information. When you are finally connected to the server, you’ll need to set up a python virtual environment. This is done by typing in the command "sudo apt-get install python3-pip" followed by "sudo pip3 install virtualenv"
Now we’ll need to enter that virtual environment. This is done by using the commands "python3 -m venv .venv" and "source .venv/bin/activate". You should see "(.venv)" like so
Afterwards, we need to write the code for a Discord bot. Fortunately, I’ve done it for you and will only need to be downloaded from my GitHub. Remember to change the TOKEN value as seen here:
When you’re done, switch to a new screen session and run the bot using the command "python3 bot.py". Don’t forget to also invite the bot to your server (with read and write permissions)!