Discord Bot: Canary Cowboy
A super simple Discord Bot built and deployed with Architect.
Contents:
Bot Setup
•
Architect
•
Discord Bots
Reference:
arc.codes
•
discord.com/developers/docs
Set up this Discord bot with the single /chirp
command. These are the steps to get up and running if you generally understand how Discord bots work and grok Architect.
Add environment variables to your .env
file:
APPLICATION_ID=
CLIENT_PUBLIC_KEY=
SECRET_TOKEN=
And use arc env
to set these in AWS.
Run ./scripts/register-commands.mjs
to register the bot commands with Discord.
node ./scripts/register-commands.mjs
Visit the root handler and follow the install link.
Send a message to a channel with the /chirp
command.
(You may need to reload the Discord UI to see the new command.)
Architect (aka "Arc") is a toolchain to help build and deploy "serverless" applications to AWS. It has several primitives for defining HTTP Lambdas, SQS queues, DynamoDB tables, and more.
These are defined in the ./app.arc
file.
Arc emulates these services locally, so you can build/test offline.
This bot has 2 HTTP Lambdas (one is just the root GET /
handler). The main function handles POST /interactions
from Discord and replies with a simple message.
Discord bots have all sorts of capabilities. This one is a simple "slash command" bot, which means it filters incoming POST messages for a specific "chirp" command and replies with a chat message.
This bot does not use the "gateway" websocket API (though, it could). It's just a webhook implementation that waits for a POST request from Discord and replies with a simple message.