Based on notes from a presentation given to the Port Townsend Web Developers Meetup on Jan 13 2021.
Discord is an American VoIP, instant messaging and digital distribution platform designed for creating communities. Users communicate with voice calls, video calls, text messaging, media and files in private chats or as part of communities called "servers." Servers are a collection of persistent chat rooms and voice chat channels.
Much like Slack but more focused on gaming than business. Some overlap.
- Some limited integrations, Twitch and YouTube (gamer oriented)
- Supports webhooks, ie. from Github
- more focus on "bots"
The Discord desktop and web client is built on the Electron framework.
Officially Vetted Libraries for Integration with many languages
This example code uses Discord.js
https://github.com/chalda/DiscordBot
Bots have an
- ID
- public key
- secret key
- token (used to invite them to a guild)
OAuth supported (required?) for larger bots
Uses Twitter "snowflake" for IDs. see https://discord.com/developers/docs/reference#snowflakes
"True consistency is impossible." "Eventually consistent." You may receive events 0-N times. "Clients should operate on events and results from the API in as much of an idempotent behavior as possible."
Some things are done via HTTP. Most via websockets
https://discord.js.org/#/docs/main/stable/general/welcome
https://discord.com/developers/docs/topics/gateway#gateways
https://discord.com/developers/docs/topics/gateway#list-of-intents
https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
- REST interface, results as JSON
- https://discordapp.com/api/v8/{path-to-resource}
- User-Agent required
- Authorization header required,
Bot <your secret>
e.g., to access a specific Guild
GET https://discordapp.com/api/v8/guilds/:guildID
User-Agent: DiscordBot
Authorization: Bot <your secret here>
You will mainly be dealing with these Gateway Events
Alternatively, check out the list of events fired by a Discord.js Client
As you can see, there are a lot, but bots tend to work most with these: (most also have update and delete)
CLIENT_READY: 'ready', MESSAGE_CREATE: 'message', GUILD_CREATE: 'guildCreate', CHANNEL_CREATE: 'channelCreate',