Serenity
Todo List Bot
Prerequisites
In this example we will deploy a Serenity bot with Shuttle that can add, list and complete todos using Application Commands. To persist the todos we need a database. We will have Shuttle provision a PostgreSQL database for us by passing #[shared::Postgres] pool: PgPool
as an argument to our main
function.
To run this bot we need a valid Discord Token. To get started log in to the Discord developer portal.
- Click the New Application button, name your application and click Create.
- Navigate to the Bot tab in the lefthand menu, and add a new bot.
- On the bot page click the Reset Token button to reveal your token. Put this token in your
Secrets.toml
. It’s very important that you don’t reveal your token to anyone, as it can be abused. Create a.gitignore
file to omit yourSecrets.toml
from version control.
To add the bot to a server we need to create an invite link.
- On your bot’s application page, open the OAuth2 page via the lefthand panel.
- Go to the URL Generator via the lefthand panel, and select the
applications.commands
scope. - Copy the URL, open it in your browser and select a Discord server you wish to invite the bot to.
For this example we also need a GuildId
.
- Open your Discord client, open the User Settings and navigate to Advanced. Enable Developer Mode.
- Right click the Discord server you’d like to use the bot in and click Copy Id. This is your Guild ID.
- Store it in
Secrets.toml
and retrieve it like we did for the Discord Token.
For more information please refer to the Discord docs as well as the Serenity repo for more examples.
Was this page helpful?