Follow these instructions after deploying this repo on Cyclic.sh
Navigate to Discord's developer portal and create a new application
After creating the application, you are taken to the application's dashboard. There you can configure an app icon, description, etc.
Retrieve:
APPLICATION ID
PUBLIC KEY
On the left hand side, go to Bot
then click on Add Bot
You will need to create the bot token.
Press Reset Token
and confirm.
Retrieve the TOKEN
string.
The easiest way to add the bot to your server is via url.
Go to OAuth2
> URL Generator
on the left, select the permissions:
applications.commands
- allows you to register slash commandsbot
- this will show additional permissions for the botSend Messages
- to allow the bot to send messages
Copy and navigate to the generated URL at the bottom.
The page will ask you to select a server to install your bot on, it will go through a few prompts to verify that you are human.
After you authorize, the bot will appear in your server.
Keep in mind, the bot does not yet have any code running, so it will not do anything just yet
To get the server id, you first have to enable developer mode for in your discord user settings > advanced:
With developer mode on, you will be able to right click the discord server name to copy it's id:
Developer mode allows you to right click all kinds of things in discord to get their id's (channels, users, messages, etc.)
At this point, make sure you've collected all the variables you will use in your environment
This step is VERY IMPORTANT, it lets discord know the url at which the bot is running. Discord will send interaction event payloads to this endpoint.
When you first enter the endpoint into the ui, discord will make a cryptographically signed request to your endpoint and expect you to verify the signature. This will establish trust between discord and your hosted bot.
- Make sure your bot is deployed to Cyclic
- Before entering the endpoint make sure the environment variables have been properly configured and that
process.env.PUBLIC_KEY
is set. - Enter the endpoint url into discord and Save Changes
- The interactions endpoint is using the
verifyKeyMiddleware
function to verify the keys automatically -
app.post('/interactions', verifyKeyMiddleware(PUBLIC_KEY), async (req, res) => {
...
- Make sure all of the environment variables have been correctly set up
- Make a
GET
request tohttps://[your bot's url].cyclic.app/register_commands
This route makes a put request to register a/yo
command on your discord severapp.get('/register_commands', async (req,res) =>{
Refer to the discord docs to extend this further
After registering commands, you should see them available in your discord server