This bot is designed to automatically fetch new announcements and assignments from your Canvas courses and post them in a designated Discord channel. The bot will also send reminders for assignments with a 7 day, 3 day, and 1 day notice.
-
Visit: Discord Developer Portal
-
Navigate to OAuth2 -> OAuth2 URL Generator -> bot.
-
Under bot permissions, select administrator. (Don’t worry, its permissions are limited by the
intents.bitfields
we set. See Discord Intents for more info.) -
Copy the generated URL at the bottom and open it in a new tab. This will let you invite the bot to your server. (Make sure you have admin permissions on the server to do this.)
- Run
npm install
. - Create a
.env
file (use the example provided). - In your Discord application, go to bot -> reset token, and set this as the
DISCORD_TOKEN
in your.env
. - Generate your Canvas API token via Canvas Settings and set this as
CANVAS_API
. - Update the
CANVAS_COURSES_URL
andCANVAS_BASE_URL
with your institution's Canvas domain. Replace<YOUR-CANVAS-LINK>
with the appropriate domain for your school.
This could be for example:canvas.kdg.be
Ensure you only change the domain part (e.g., github.be
) to match your institution's Canvas domain.
- Add your
SERVER_ID
andBOT_ID
to the.env
. This will help you set commands faster without the typical wait. (Find yourSERVER_ID
by right-clicking your server icon -> Copy Server ID, and yourBOT_ID
by right-clicking the bot in the server -> Copy User ID). Make sure to enable discord developer tools (User settings -> Advanced -> enable "Developer mode") for this to be an available option.
- Run the queries in the
discordbot_setupdb.sql
file from the repository to set up your database correctly. - Use the command
/addChannelWithCourse Course_id Channel_id ChannelName
to link courses with channels. - Fill in your database details in the .env file:
DB_HOST=""
DB_USER=""
DB_PASSWORD=""
DB_NAME=""
We've built several useful slash commands to enhance the user experience and give your users access to important course information.
- This command allows you to add a course to the server. You will have to fill in the following:
- Course_id (the number found in the URL when you have a canvas course opened, for example 49715).
- Course_name (the name of the course, this can be anything you like).
- Channel_discord_id (the ID of the designated discord channel you want to link the course to).
- You can get this ID by right-clicking on a text-channel and selecting "Copy Channel ID" (make sure you have developer mode enabled for this to show up!).
- This command will ask for a
course_name
and fetch the latest announcement (if available) from that course. The result is visible only to the user who requested it.
- This command will ask for a
course_name
and return all upcoming assignments. Again, only visible to the requesting user.- (Note: If multiple assignments share the same due date, they will all be shown.)
- This command returns a list of all active courses in the database. Super handy when you’re adding new channels or checking course availability.
And that's it! 🎉 You’re now ready to deploy your CanvasBot and stay on top of announcements and assignments in Discord. Enjoy!
Gilles Serrien - serriengilles@gmail.com - LinkedIn - [Discord: kingykongiee]
Rinus Van Linden - rinus.vanlinden@gmail.com - LinkedIn - [Discord: dark3art]