1 of 15

DISCORD.PY

TRIVIA GAME BOT!!!

Gamers are y’all ready?

acmcsuf.com/discord-workshop

2 of 15

01

02

03

04

GAME PLAN

SETTING UP

TESTING

CODE-ALONG

REVIEW

Getting some bot code up

Writing the bot commands

See if the bot works!

Go over what we learned

acmcsuf.com/discord-workshop

3 of 15

SETTING UP

01

Let’s set up our Discord Bot together!

acmcsuf.com/discord-workshop

4 of 15

Setup Steps

Write a discord.py bot!

Create a bot token and�a test server

Install discord.py and�the bot token

DISCORD

CODE

PYTHON

acmcsuf.com/discord-workshop

5 of 15

acmcsuf.com/discord-workshop

6 of 15

Bot Template

To save time, let’s grab the bot template!

  • git clone https://libdb.so/discord-workshop-env
  • cd discord-workshop-env

acmcsuf.com/discord-workshop

7 of 15

Installing Python

Nix ❄️

  • nix-shell

Replit ⠕

Fork acmcsuf.com/discord-workshop-replit (template included)

Locally 💻

Clone the template, then enter the Python virtualenv, then run pip install.

Local installation will not be covered. Use Nix ❄️ if you don’t already know this!

acmcsuf.com/discord-workshop

8 of 15

CODE-ALONG

02

Let’s being coding up our bot!

acmcsuf.com/discord-workshop

9 of 15

TESTING

03

Let’s see if our bot really works now!

acmcsuf.com/discord-workshop

10 of 15

REVIEW

04

What have we learned so far?

acmcsuf.com/discord-workshop

11 of 15

Creating A Command Tree

  • Created a tree of different slash commands that the user can use!

.

├── /join ​

├── /start

├── amount ​

├── category ​

└── difficulty ​

├── /answer

└── answer ​

acmcsuf.com/discord-workshop

12 of 15

Sending Embed Messages

  • Created nice-looking embed messages to enhance your bot!

acmcsuf.com/discord-workshop

13 of 15

Ideas to Further your Bot

/restart

/leaderboard

/hint

Restart your game using a slash command instead of restarting your bot everytime!

Create a nice looking embed showcasing the leaderboard throughout the game!

Allow users to have only one hint throughout the game!

acmcsuf.com/discord-workshop

14 of 15

THANKS!

Please ask us questions!

Also join our Discord!

acmcsuf.com/discord @ #dev-chat

Workshop by acmDev

CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, and infographics & images by Freepik

15 of 15

Please mark your attendance!

acmcsuf.com/dev-attendance