Git Product home page Git Product logo

discord-events's Introduction

discord-events

Re-inventing for fun an AWS-backed Discord bot to schedule events.

๐Ÿ•Œ Design

Infra

Java bot runs in a ECS-managed Docker image on an EC2 instance. It uses VPC endpoints to store and read into a DynamoDB Table holding the events. These interactions are hidden from the Internet.

Bot

Powered by Discord4J.

Main features

  • Manage events (create, view, & delete) for multiple discord servers.

  • Attend events using Discord emoji reactions.

Reminder feature

Opt-in feature where a separate thread in the bot checks for events and notifies a channel 15 minutes before it occurs.

๐Ÿ›  Bot Setup

  • Prod bot: Auto-scaled ECS service running the Java app with its own AWS DDB table
  • Dev bot: Containerized Java app running locally with its own AWS DDB table
  1. You can have two application instances: discord-events-bot for prod and discord-events-bot-test for dev. Create an application and associated bot for each desired instance through Discord developer portal.
  2. Enable all Privileged Gateway Intents for each bot on the Discord developer portal.
  3. Add each bot to your desired servers with the following link (use CLIENT ID token from developer portal): https://discordapp.com/api/oauth2/authorize?scope=bot&client_id=<YOUR CLIENT ID>.
  4. Set env vars in your shell:
    Name Description
    AWS_ACCOUNT AWS account ID
    AWS_DEFAULT_REGION AWS region (ex: us-east-1)
    AWS_ACCESS_KEY_ID * AWS credentials
    AWS_SECRET_ACCESS_KEY * AWS credentials
    DISCORD_BOT_TOKEN Bot token from Discord Developer Portal
    DISCORD_EVENTS_ENV Execution env for discord-events (dev|prod)
    DISCORD_EVENTS_TABLE_NAME Name your DDB table, the app will differentiate that of dev and prod

* Any AWS credentials setup can replace these for the bot's Java execution.

Switching between prod and dev bots

You can switch bots by changing the following env vars in your shell:

  • DISCORD_BOT_TOKEN
  • DISCORD_EVENTS_ENV

Aliases should do the trick:

alias botProd="export DISCORD_BOT_TOKEN=<your prod bot token> && export DISCORD_EVENTS_ENV=prod"
alias botDev="export DISCORD_BOT_TOKEN=<your dev bot token> && export DISCORD_EVENTS_ENV=dev"

๐Ÿค– Running the bot locally

  1. Deploy the CDK dev stack
    1. Switch to your dev bot
    2. cd discord-events-cdk
    3. yarn install && yarn run build
    4. yarn run cdk deploy DiscordEventsDevStack
  2. From root dir, docker-compose up

โ˜ Deploy the bot to AWS

  1. Switch to your prod bot
  2. cd discord-events-cdk
  3. yarn install && yarn run build
  4. yarn run cdk deploy DiscordEventsStack

You can always have your CI/CD pipeline deploy the newest version of your bot, just make sure that all the necessary environment variables (as indicated in setup) are set in the pipeline execution.

๐Ÿคฎ Hardcoded stuff

  1. Timezone defaulted to Eastern Canada, change in utils/DateUtils.java.

๐Ÿ‘ฉ๐Ÿพโ€๐Ÿ’ปUsage

Command Example
!create-event [title:str] [date:date] [time:time] [description:str]?
!delete-events [deleteCode:str]*
!my-events
!list-events [[upcoming:num]] [[on:date]] [[from:date] [to:date]]
!remind-events [on/off:str]?
!attend-events
!help-events

๐Ÿ“– Resources

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.