Skip to content

Latest commit

 

History

History
173 lines (122 loc) · 6.41 KB

README.md

File metadata and controls

173 lines (122 loc) · 6.41 KB

Zoe Bot

Description

Discord bot that traverses through the Riot Games API to find information about players of the game League of Legends.

Table of Contents

Prerequisites

Zoe is an IaC monorepo application that utilizes SST and Discord. Make sure to have the following installed and configured.

Overview

Bot Commands

  • /help - command list
  • /setup - create guild instance
  • /reset - reset instance
  • /region <region> - change guild region
  • /acknowledge - acknowledge dangerous commands
  • /adduser <username> - add user to guild, user must be a valid League of Legends username
  • /deluser <username> - delete user from guild, user must be a valid League of Legends username and exist
  • /userlist - display guild userlist
  • /speak - zoe will talk to you

CloudFormation Stacks

  • InfraStack - creates DynamoDb table to store user information
  • BotStack - creates Lambda functions and events for Discord bot
  • WebStack - creates Next.js web app for frontend UI

Applications

Initial Setup

Create Discord Application

  1. Create a new Application

  2. Enable Privileged Gateway Intents under Bot

  3. Invite to server with https://discord.com/oauth2/authorize?client_id=<client_id>&permissions=536870912&scope=applications.commands%20bot

    Note: Replace <client_id> with Application ID

  4. After deploying the bot to AWS using either npm run deploy or npm run deploy:prod, paste InteractionsEndpoint into Interactions Endpoint URL under General Information

Configuration

Set environment configuration config.json

{
  "aws_region": "<AWS REGION>",
  "riot_key": "<RIOT API KEY>",
  "discord_public_key": "<DISCORD PUBLIC KEY>",
  "application_id": "<DISCORD APPLICATION ID>",
  "token": "<DISCORD BOT TOKEN>"
}

Bot Deployment

Startup

The bot is configured to be able to deploy to multiple stages. This changes configurations in the AWS stack.

  • npm run deploy - deploy dev stack, returns InteractionsEndpoint
  • npm run deploy:prod - deploy prod stack, returns InteractionsEndpoint, URL

Production Deployment

Create Redirect

  1. In the Discord Application on Discord Developer Portal under OAuth2, create a redirect URL using URL/load

    The redirect URL will look like this https://abcdefghijklm.cloudfront.net/load

  2. Under Authorization Method, choose In-app Authorization

  3. Enable Scopes: bot, application.commands

  4. Enable Bot Permissions: Manage Webhooks

Integrate with GitHub Actions

Create IAM Role

Instructions to deploy SST apps using GitHub Actions can be found here

Create Secrets

Automated Setup

  1. Set environment configuration config.actions.json
{
  "pat": "<GITHUB TOKEN>",
  "owner": "<GITHUB REPO OWNER>",
  "repo": "<GITHUB REPO>",
  "aws_account_id": "<AWS ACCOUNT ID>",
  "aws_region": "<AWS REGION>",
  "riot_key": "<RIOT API KEY>",
  "dev": {
    "discord_public_key": "<DISCORD PUBLIC KEY>",
    "application_id": "<DISCORD APPLICATION ID>",
    "token": "<DISCORD BOT TOKEN>"
  },
  "prod": {
    "discord_public_key": "<DISCORD PUBLIC KEY>",
    "application_id": "<DISCORD APPLICATION ID>",
    "token": "<DISCORD BOT TOKEN>"
  }
}
  1. In configs, create secrets used by GitHub Actions using npm run start

Manual Setup

  1. In the repo, under Settings > Secrets and variables > Actions, create three new repository secrets

    • AWS_ACCOUNT_ID
    • AWS_REGION
    • RIOT_KEY
  2. Repeat step 1 for Secrets and variables > Dependabot

  3. Additionally, create a new environment called dev and create three new environment secrets

    • APPLICATION_ID
    • DISCORD_PUBLIC_KEY
    • TOKEN
  4. Repeat step 3 for prod

Status

Deployment Status

Quality Gate Status Security Rating Reliability Rating Maintainability Rating