Giter Site home page Giter Site logo

simplebot's Introduction

Simplebot

This is a simple introductory Discord bot leveraging AWS free-tier services.

To get started:

Pre-reqs:

  • AWS account for setting up Lambda
  • Discord Developer Portal
  • Node.js

1. Setup of AWS Lambda:

  • Create a Lambda function
  • Runtime set to Node.js
  • Architecture set to x86_64
  • Open Advanced Settings and check Enable function URL
    • Auth type: NONE
    • check Configure cross-origin resource sharing (CORS)
    • leave the rest default

2. Setup of Nodejs:

NOTE:
Discord security verification requires tweetnacl.

  • On local machine, create a new directory i.e. lambda_files to store node_modules as well as .js files for Lambda
    • run npm i tweetnacl
  • Setup your index.js and any other files
  • Zip within the folder, including node_modules, and upload to Lambda function

3. Setup of Discord Application:

NOTE:
Assign permissions based on the needs of your function; DO NOT grant Administrator.

  • Create a new Application on the Discord Developer Portal
  • In the Application's settings, navigate to the "OAuth2" section, and generate the URL with the following Scopes:
    • application.commands
    • bot
  • Bot Permissions
    • use slash commands
  • Copy the Public Key from the Discord Application and set it as an Environment Variable named "PUBLIC_KEY" in the Lambda configuration
  • Copy the function URL from Lambda and use it as the Discord Interactions Endpoint URL

4. Registering Commands:

NOTE:
To register commands we use axios to query and post to Discord API.
Secrets are stored in .env which uses dotenv.

  • On local machine, create a new directory separate from lambda_files
    • run npm i axios dotenv
  • update the .env file with your BOT TOKEN, APP ID, and GUILD ID
  • run node register.js script

TIP:
Global commands could take up to 1 hour to create, delete or modify. If you need to update a command quickly for testing you can create it as a guild command.

Optionals:

If you plan on using DynamoDB run npm i @aws-sdk/client-dynamodb

Addt. Resources:

simplebot's People

Contributors

kastleghost 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.