premint / premintbot

11 stars 3 forks source link

premintbot

A Discord bot for Premint.

Instructions for setting up the bot can be found at SETUP.md

Endpoints

Slash Commands

Bang Commands

How to run locally

Setup gcloud credentials (only need to do this once):

gcloud iam service-accounts create local-dev
gcloud projects add-iam-policy-binding premint-343516 --member="serviceAccount:local-dev@premint-343516.iam.gserviceaccount.com" --role="roles/owner"
gcloud iam service-accounts keys create credentials.json --iam-account=local-dev@premint-343516.iam.gserviceaccount.com

Never commit or share credentials.json.

Make sure env variables are set in ~/.zprofile:

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"
export PREMINTBOT_DISCORDAUTHTOKEN="REDACTED"
export PREMINTBOT_GOOGLECLOUDPROJECT="premint-343516"

Run the app:

make dev

How to run tests

make test

How to install the bot

https://discord.com/oauth2/authorize?client_id=950933570564800552&scope=bot%20applications.commands&permissions=268438552

TODO: Make sure the permissions are correct

How to deploy

Run:

make ship

How to set env variables in Cloud Run

gcloud run services update premintbot --set-env-vars PREMINTBOT_DISCORDAUTHTOKEN=REDACTED,PREMINTBOT_GOOGLECLOUDPROJECT=premint-343516

Database (Firestore)

https://console.cloud.google.com/firestore/data/guilds?referrer=search&project=premint-343516

Bot Pinger

Cloud Scheduler link, runs every 5 min: https://console.cloud.google.com/cloudscheduler?project=premint-343516

BigQuery Events

These events are used for debugging:

guilds.create

When a bot joins the server

Field Type
GuildID string
GuildName string
GuildAdminRoleID string
OwnerID string
GuildAdmins []string
Message string
Timestamp time.Time
UserID string

guilds.admin_action

When an admin performs an action

Field Type
GuildID string
UserID string
Timestamp time.Time
ActionType string
Message string

commands.slash_premint

When someone uses the /premint command

Field Type
GuildID string
UserID string
Timestamp time.Time
Registered boolean
WithAddress boolean