Special Discord Edition #987
EthanThatOneKid
started this conversation in
Newsletter
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Special Discord Edition
Self link: https://acmcsuf.com/special-discord-edition/
Created: Nov 29th, 2023
This special edition of the mini-workshop series serves as a reference for
building projects utilizing Discord API concepts. Designed as a handbook, this
blog post is tailored to guide you in deploying your project to operate beyond a
local environment, ensuring it remains functional even when your computer is
offline.
Table of contents
yourself to help you decide what you need to build your Discord project.
A table summarizing the differences between the three types of Discord
projects.
building your Discord project.
Discord API
This section serves as an introduction to the Discord API.
Note
The content of this blog post is not meant to be totally comprehensive. Please
reference Discord's official
API Reference documentation
for more information.
Discord API concepts
Discord credentials
In order to use the Discord API, you need to
create a new Discord application
which contains the credentials necessary to authenticate your project with
Discord.
Scopes, permissions, and intents
Edit your application's invite URL to specify the scopes and permissions your
application needs. See Discord's documentation on
creating an invite
for more information.
From your Discord application's dashboard, you can build an invite URL with the
scopes and permissions you need.
Discord applications dashboard,
click on your application.
your server.
Update the privileges of your application's bot to specify the intents that your
application needs as needed.
Discord applications dashboard,
click on your application.
Questions to ask yourself
Decisions decisions decisions. Need a refresher to help you decide what you
need? Here are some questions to ask yourself.
Does your project listen to real-time events on Discord?
Examples of what real-time events are:
Implications:
Special considerations:
hosting provider such as
Fly.io,
Render, etc.
According to
Vercel's documentation:
Library recommendations, listed without a specific order as of the last edit:
Arikawa v3
Harmony.
connection to Discord. See
Discord's official list of libraries
for more information.
Does your project respond to Discord interactions?
Examples of what Discord interaction are:
input (a.k.a. slash) command.
Discord interaction types:
PING
(Discord heartbeat)APPLICATION_COMMAND
MESSAGE_COMPONENT
APPLICATION_COMMAND_AUTOCOMPLETE
MODAL_SUBMIT
The interaction type is included in the
type
field of the interaction object.Implications:
serverless function or a traditional web server.
Special considerations:
serverless function provider supports serverless functions that respond to
HTTP requests such as
Vercel,
Deno Deploy,
Cloudflare Workers,
etc. See Discord's tutorial on
Hosting a Reddit API Discord app on Cloudflare Workers.
traditional web server is accessible via a URL. Deploy your web server to a
hosting provider such as
Fly.io,
Render, etc.
According to
Vercel's documentation:
Library recommendations, listed without a specific order as of the last edit:
build a Discord interaction server with any web framework that supports
responding to HTTP requests. Tip: Use a library for helping you type-check
your project, such as
discord_api_types if you are using
TypeScript
(example projects by @acmcsufoss).
capabilities. See
Discord's official list of libraries
for more information.
discord_app
leverages TypeScript's type system to ensure type-safety indefining application commands, utilizing your application command schema to
inject type information into your interaction handlers. See
deno.land/x/discord_app for more
information.
Relevant documentation as of the last edit:
Does your project send messages to a Discord channel?
Discord webhook capabilities:
Implications:
can send HTTP requests e.g. serverless function, traditional web server,
workflow script, etc.
Relevant documentation as of the last edit:
Does your project access Discord user data or allow users to login with Discord?
Discord OAuth2 capabilities:
Implications:
can send HTTP requests e.g. serverless function, traditional web server,
workflow script, etc.
OAuth2 login page. This means your project may need to be accessible via a
URL, most likely a website. See
Discord's State and Security documentation
for more information.
Websocket server versus interaction server versus webhook
Here is a table summarizing the differences between the three types of Discord
projects.
Is your project a Discord Activity?
Discord Activity capabilities:
with it in real time together.
Discord bot e.g. MMO RPG adventure, shared drawing canvas, etc.
Implications:
Game SDK.
Example projects
Here are some example projects to reference when building your Discord project.
Conclusion
We hope this blog post helped you decide what you need to build your Discord
project. If you have any questions, feel free to reach out to Ethan on Discord
at
EthanThatOneKid
. Written with 💜 by@acmcsufoss.
Note
Edit (Mar 21, 2024): Open Source Software team board member Owen Sterling presented the "Discord Bot Intro" workshop, https://acmcsuf.com/discord-bot-intro, where he walked through every step required to write a Discord bot, https://github.com/JOwen-ster/Discord_Bot_Workshop, from scratch.
Beta Was this translation helpful? Give feedback.
All reactions