This repo contains the code that runs the Gitpod Community Discord Bot.
Community contribuitions are welcome! 🧡 Please create an issue and open a Gitpod workspace from that context.
You wanna contribute!? That sounds awesome! Thank you for taking the step to contribute towards this project :)
- Login on https://discord.com/developers/applications
- Create a new app by clicking on
New Application
on the top right - Inside your bot page, click on 🧩
Bot
from the left sidebar and thenAdd Bot
button- In the same page, toggle on the following options:
Presence Intent
,Server Members Intent
andMessage Content Intent
- In the same page, toggle on the following options:
- Go to OAuth2 > URL Generator from your left sidebar
-
If you don't have
./BotConfig.toml
file, create it by copying ./ExampleBotConfig.toml. So, you could run:cp ExampleBotConfig.toml BotConfig.toml
-
Update/fill-up
./BotConfig.toml
with the token from your 🧩Bot
page on discord dev portal. You might need to reset it to see. -
To persist the config changes accross development Gitpod workspaces:
# Run this every time after making changes to ./BotConfig.toml
gp env DISCORD_BOT_CONFIG_ENCODED="$(base64 -w0 BotConfig.toml)"
- In Gitpod terminal, run the BOT in the following manner:
cargo run
Note You can also explicitly specify a path for your config. For example:
# From cargo
cargo run -- BotConfig.toml
# From a release binary
./target/release/optimus /some/arbitrary/path/to/your_config.toml
Some (optional) features use Meilisearch, GitHub and OpenAI API.
Note: This part is undocumented, will be done soon.
Minimal resource requirements:
- optimus bot: 13-20MB RAM
- [optional] meilisearch: 100MB RAM (for indexing)
In conclusion, a server with 128MB RAM (+SWAP), shared CPU and 1GB storage will do.
- WIP (will be written soon)
- WIP (will be written soon)
Docker would come handy in case you want something that JustWorks™️.
Preparing the config:
# Get the sample config
curl -o BotConfig.toml -L https://raw.githubusercontent.com/gitpod-io/optimus/main/ExampleBotConfig.toml
# Update the config with your bot token and application ID
vim BotConfig.toml # or nano, or any other editor
Starting the container:
# You can also start in detached mode by passing `-d` to `run` subcommand
docker run --init --name optimus -v $(pwd)/BotConfig.toml:/app/BotConfig.toml -t ghcr.io/gitpod-io/optimus:main
# You can press Ctrl+c to stop
# If using meilisearch, its database will be stored at `/app/data.ms` inside the `optimus` container
Restarting the container:
# Ensure it's stopped
docker container stop -t 2 optimus
# Starts and attach to it
docker container start -a optimus
# Press Ctrl+c to detach
# To attach back
docker attach optimus
# In case you want to stop again:
docker container stop -t 2 optimus
If you are hardware resource constrained, you can use the barebones or systemd method instead.
The docker method is enough, using docker-compose for this would be overkill in terms of hardware resources 🌳
- Create a f1-micro (~600MB RAM) Linux VM from Compute Engine > VM Instances. For example, with
gcloud
CLI:
gcloud compute instances create discord-optimus-bot \
--zone=us-central1-a \
--machine-type=f1-micro \
--network-interface=network-tier=PREMIUM,subnet=default \
--maintenance-policy=MIGRATE \
--provisioning-model=STANDARD \
--create-disk=auto-delete=no,boot=yes,device-name=discord-optimus-bot,image=projects/ubuntu-os-cloud/global/images/ubuntu-minimal-2204-jammy-v20230302,mode=rw,size=10 \
--no-shielded-secure-boot \
--no-shielded-vtpm \
--no-shielded-integrity-monitoring \
--labels=ec-src=vm_add-gcloud \
--reservation-affinity=any
- WIP (will be written soon)
- https://github.com/gitpod-io/gitpod-qa (AI powered chatbot)