Coder Social home page Coder Social logo

pong1217 / serverless-discord-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ytausch/serverless-discord-bot

0.0 0.0 0.0 140 KB

A serverless Discord Bot template built for AWS Lambda based on Discord's slash commands and the slash-create library.

License: MIT License

JavaScript 100.00%

serverless-discord-bot's Introduction

serverless-discord-bot

A serverless Discord Bot template built for AWS Lambda based on Discord's slash commands and the slash-create library.

Introduction

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

Credentials

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

Setup

  1. Login to the AWS Management Console
  2. Create a new Secrets Manager secret
    • Secret Type: other
    • Add your Discord credentials (see above)
    • Set the name of the secret to /dev/serverless_discord_bot/discord
  3. Install the AWS SAM CLI. You can optionally also install the AWS Toolkit extension for your IDE.
  4. Clone this repository.
  5. Add your commands in 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.
  6. Run npm install in the commands layer folder (src/commands_layer/nodejs)
  7. To build and deploy the application, run the following in your shell (alternatively use AWS Toolkit):
sam build
sam deploy --guided
  1. Copy the API Gateway endpoint URL stack output and paste it in the Discord Developer Portal as Interactions Endpoint URL.
  2. Have some fun and build something great!

Usage

Updating your commands

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.

Documentation

serverless-discord-bot's People

Contributors

ytausch avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.