domo is a Discord bot to help you manage your FOMO (fear of missing out).
It sends a notification when people join a voice channel in your server. I made this because I found myself frequently checking a server to see if anyone was there and LFG. Now I can rely on domo to push this info to me instead.
The bot is added to a server and listens to voice state update events. When it encounters an event of someone joining a voice channel it posts a message to a configured text channel. Once installed in a server, users can mute the bot or the update channel if they don't want to receive domo updates.
Initially the update messages were a bit spammy so a configurable rate limit was added. This can be used to prevent someone rapidly joining and leaving a channel from spamming messages.
NOTE: At the moment this is only a private bot. You can self-host using the code and deployment instructions in this repo.
Complete the authorization flow by visiting the following link:
This link identifies the domo
app id and includes the required permission set:
- Read Messages/View Channels
- Send Messages
- Send Messages in Threads
The domo config (JSON file) must be updated for each server domo is added to. This is inconvenient but is fine for now since the goal isn't to make this a public bot. It also saves the hassle of integrating a secondary storage system.
Update config/bot_main.json
with the server's GuildID
and a channel ID
where domo
has permission to post messages. This channel is where domo
will publish its update messages. A rate_limit_sec
value can also be
configured to limit how often domo
posts.
To avoid accidentally revealing when people join private voice channels the
bot filters voice events when the voice channel category does not match the
domo update channel category. This means if domo is configured to update a
text channel in the Main
category it will only report voice channel joins
in the Main
category. The lack of a category (root) will match other voice
channels in root.
This is a bit of a hack to avoid dealing with comparing the visibility of
the text channel with each voice channel. The proper way to do this would be
to compare identify all roles/users which can see the update channel: T
.
Then identify all roles/users which can see the voice channel from the event:
V
. Then verify that V
is a superset of T
before posting.
The channel category acts as a reasonable proxy for visibiltiy because you can configure all channels in a category to have the same visibility.
Download and install Go: Instructions
To run the bot first grab the token from the bot page. Then run the bot using the run command below:
go run cmd/bot/main.go -t ${TOKEN_GOES_HERE}
This registers the bot to listen for events in the Dev Server.
To run the bot using the main config:
go run cmd/bot/main.go -t ${TOKEN_GOES_HERE} -c config/bot_main.json
NOTE: This may result in duplicate update messages from the bot deployed to Google Cloud.
Github Actions workflows are used to test pull requests. Alternatively you
can locally run ./scripts/presubmit_go.sh
or go test ./...
.
Deployment requires two tools be installed:
gcloud
is used to authenticate and configure the GCP project- Install Instructions
- Linux:
sudo apt-get install google-cloud-sdk
ko
is used to build a docker container for the bot binarygo install github.com/google/ko@latest
Once these tools are installed the following script can be run to build and deploy a new container version:
./scripts/deploy.sh
NOTE: This relies on some manually configured defaults which were set up in Cloud Console. The most notable are "secrets" which are used to provide the container the bot config (JSON file) and discord token (env var).
Below is a historical account of how this was configured:
- Visit https://discord.com/developers/applications
- Create a new application
- Within the app go to "Bot section and create a bot
- Disable "Public Bot": this prevents random people adding it to their servers
Terraform is used to configure the cloud infra to run the bot. It is currently configured on GCP. Steps:
- Create a GCP project
- Create a GCS bucket for terraform state
- Install
terraform-cli
: https://learn.hashicorp.com/tutorials/terraform/install-cli - Set the project id in
terraform/main.tfvars
- Set the Terraform bucket id in
terraform/main.tf
(can't be set as a variable) - Export the project id as an env var:
GOOGLE_PROJECT=$PROJECT_ID
- Run terraform
terraform -chdir=terraform init terraform -chdir=terraform validate terraform -chdir=terraform plan -var-file=main.tfvars terraform -chdir=terraform apply -var-file=main.tfvars
- Application Links
- discordgo docs: https://pkg.go.dev/github.com/bwmarrin/discordgo
- Useful Guides
- Google Cloud docs
- Discord API pages