Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tbeseda/discord-canary-cowboy
Super simple Discord bot with Architect
https://github.com/tbeseda/discord-canary-cowboy
Last synced: about 1 month ago
JSON representation
Super simple Discord bot with Architect
- Host: GitHub
- URL: https://github.com/tbeseda/discord-canary-cowboy
- Owner: tbeseda
- Created: 2024-02-23T21:13:33.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-02-27T18:44:40.000Z (12 months ago)
- Last Synced: 2024-04-15T02:57:45.109Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 313 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
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## Bot Setup
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.
### Create a new Discord Application
Add environment variables to your `.env` file:
```sh
APPLICATION_ID=
CLIENT_PUBLIC_KEY=
SECRET_TOKEN=
```And use `arc env` to set these in AWS.
### Register bot commands
Run `./scripts/register-commands.mjs` to register the bot commands with Discord.
```sh
node ./scripts/register-commands.mjs
```### Deploy to AWS with Arc
Visit the root handler and follow the install link.
### Test the bot
Send a message to a channel with the `/chirp` command.
(You may need to reload the Discord UI to see the new command.)## Architect
[Architect](https://arc.codes) (aka "Arc") is a toolchain to help build and deploy "serverless" applications to AWS. It has several primitives for defining [HTTP](https://arc.codes/http) Lambdas, SQS [queues](https://arc.codes/queues), DynamoDB [tables](https://arc.codes/tables), and more.
These are defined in the `./app.arc` file.
Arc [emulates these services locally](https://arc.codes/docs/en/reference/cli/sandbox), 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
Discord bots have [all sorts of capabilities](https://discord.com/developers/docs/interactions/application-commands). 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.