Categorygithub.com/kn-lim/dreamingway-bot
module
0.0.0-20241029042010-311f96742e16
Repository: https://github.com/kn-lim/dreamingway-bot.git
Documentation: pkg.go.dev

# README


I'm a 🤖!

dreamingway-bot

Go GitHub Workflow Status - Build GitHub Workflow Status - Tests Coverage Status Go Report Card License

A personal Discord bot to handle miscellaneous tasks hosted on AWS Lambda.

Packages Used

Using the Discord Bot

How to Build

From the project home directory:

  • Endpoint Function: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags lambda.norpc -o binary/bootstrap ./cmd/endpoint/
  • Task Function: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags lambda.norpc -o binary/bootstrap ./cmd/task/

Build Environment Variables

NameDescription
AWS_REGIONAWS Region of the Lambda Functions

Syncing Commands with Discord

https://github.com/kn-lim/dreamingway-bot/tree/main/cmd/cli

Environment Variables

Endpoint Lambda Function

AWS

NameDescription
TASK_FUNCTION_NAMEName of the Task Lambda Function

Discord

NameDescription
DISCORD_BOT_APPLICATION_IDDiscord Bot Application ID
DISCORD_BOT_PUBLIC_KEYDiscord Bot Public Key
DISCORD_BOT_TOKENDiscord Bot Token

Task Lambda Function

Discord

NameDescription
DISCORD_API_VERSIONDiscord API Version
DISCORD_BOT_TOKENDiscord Bot Token

Pixelmon

NameDescription
PIXELMON_NAMEAWS Name Tag of Pixelmon EC2 Instance
PIXELMON_INSTANCE_IDAWS Instance ID of Pixelmon EC2 Instance
PIXELMON_REGIONAWS Region of Pixelmon EC2 Instance
PIXELMON_HOSTED_ZONE_IDAWS Hosted Zone ID of Domain
PIXELMON_DOMAINDomain of Pixelmon Server
PIXELMON_SUBDOMAINSubdomain of Pixelmon Server
PIXELMON_RCON_PASSWORDRCON Password of Pixelmon Service
PIXELMON_ROLE_IDRole ID to allow /pixelmon command

AWS Setup

  1. Create an endpoint Lambda function on AWS.
    • For the Runtime, select Amazon Linux 2023.
    • For the Architecture, select x86_64.
    • Under Advanced Settings, select:
      • Enable function URL
        • Auth type: NONE
        • Invoke mode: BUFFERED (default)
        • Enable Configure cross-origin resource sharing (CORS)
  2. Create a task Lambda function on AWS.
    • For the Runtime, select Provide your own bootstrap on Amazon Linux 2 under Custom runtime.
    • For the Architecture, select x86_64.
  3. Archive the bootstrap binary in a .zip file and upload it to the Lambda functions.
  4. In the Configuration tab, add in the required environment variables to the Lambda functions.
  5. Give the role the endpoint Lambda function is using permission to run the task Lambda function.
  6. Give the role the task Lambda function is using permission to access the AWS resources it will need.
  7. Change the Timeout of the task Lambda function to a value greater than 3 seconds.
    • The Timeout of the endpoint Lambda function can stay as 3 seconds to follow Discord's requirements.
  8. Get the endpoint Lambda function's Function URL and add it to the Discord bot's Interactions Endpoint URL in the Discord Developer Portal.
    • If it saves properly, that indicates your Lambda function is properly configured to act as a Discord bot.

# Packages

No description provided by the author