A serverless Discord Bot template built for AWS Lambda based on Discord's slash commands and the slash-create library.
A serverless Discord Bot template built for AWS Lambda based on Discord's slash commands and the slash-create library.
This repository helps you to get started with a serverless AWSLambdaServer
setup if you want to use slash-create for your discord bot running on AWS.
It contains a CloudFormation template based on AWS SAM describing the following resources:
Name | Source Folder | Description |
---|---|---|
CommandsLayer |
src/commands_layer |
Lambda layer containing the slash-create library and your custom slash commands |
CreateCommandsFunction CreateCommandsInvoker |
src/create_commands |
Lambda function that automatically syncs your commands to Discord every time you update them |
DiscordInteractionApi |
- | Amazon API Gateway HTTP API receiving incoming interaction requests from Discord |
DiscordHandlerFunction |
src/handler |
Lambda function responsible for handling and executing your commands |
Discord credentials are retrieved from an AWS Secrets Manager secret named /dev/serverless_discord_bot/discord
you have to create manually before deploying the stack.
It must contain the following (self-explanatory) key/value pairs you get from the Discord Developer Portal:
app_id
public_key
bot_token
/dev/serverless_discord_bot/discord
src/commands_layer/nodejs/commands
.
For more information, refer to the docs linked below. For a quick demo, you can use the default hello command. To use it, set your guild id in the src/commands_layer/nodejs/commands/helloCommand.js
file.
Note that global commands take up to one hour to update.npm install
in the commands layer folder (src/commands_layer/nodejs
)sam build
sam deploy --guided
To update your commands, simply edit the code in the commands directory and deploy your changes. CreateCommandsFunction
will automatically be called and sync your changes to Discord.