Skip to content

DenisHromada/rubbergod

 
 

Repository files navigation

Discord bot for the BUT FIT Discord server

About

This bot manages the verification process, karma and a bunch of other simple commands on our BUT FIT Discord server. It is written in Python with the help of Disnake and its DB runs on PostgreSQL with ORM.

Since the most of the features are custom-made, we wouldn't recommend using it for different servers.

Setup

Creating a Discord App

Before you proceed to the environment setup, you will need to create a Discord application to get the Discord API key. We will not provide you with the exact steps on how to do this as there already exists this awesome guide from the developers of Disnake, Discord API Python library.

  • When creating an invite URL in the Inviting Your Bot section, the bot and applications.commands scopes are required. We also strongly recommend choosing Administrator in the Bot permissions as it is hard to figure out which of these permissions you actually need for the development.

You should set up a separate server just for the development purposes so it shouldn't be that much of a security risk anyway.

  • After you create the Discord application, one additional step is required. You will also need to enable SERVER MEMBERS INTENT in Bot tab:

image

You can do this by going to the Discord Developer Portal and selecting your newly created application. Then click on the Bot tab on the left and scroll down to the Privileged Gateway Intents section.

Installing and running the bot

Start by cloning the repo:

git clone https://github.com/Toaster192/rubbergod.git
cd rubbergod

If you want to contribute to this project, refer to the contribution section first.

Configuration

cp config/config.template.toml config/config.toml

Now open the config.toml file in your editor. Insert the Discord API key you obtained earlier in the setup process:

1 [base]
2 command_prefix = ['?', '!']
3 default_prefix = '?'
4 ignored_prefixes = ['!']
5 key = '<Your Discord API key>'
...

Be careful. Bad things will happen if anyone else gets a possession of this key. Do not share it with anyone, ever!

On the next line, insert your Discord user ID into the array so you get administrator rights over the bot:

6 admin_ids = [<Your Discord user ID>]

Where can I find my User/Server/Message ID?

Then, create the following 5 channels (or use one channel for all of them) on your server and paste their IDs to the config:

58 log_channel = <Channel ID>
59 bot_dev_channel = <Channel ID>
60 vote_room = <Channel ID>
61 bot_room = <Channel ID>
62 mod_room = <Channel ID>

(Optional) For some features you will also need to set other config variables, usually they are divided into categories based on cogs.


Docker setup (recommended)

Install Docker Engine or (more full-featured) Docker Desktop by going to their official documentation. Just select your OS and follow the steps.

If you haven't already, run docker (systemctl start docker.service). To use Docker, you also need to be in docker group (eg. sudo usermod -aG docker $USER && newgrp docker).

It might be necessary to log out and back in or even restart your system (to get all the permissions and other stuff right).

a. Dev containers in VS Code (one click run) - preferred option

If you are using VS Code, you can simply run Rubbergod by using the Dev containers extension. Either by clicking on notification or by clicking on arrows in left bottom corner (Open a Remote Window) and choosing Reopen in container.

b. Docker Compose CLI - if you don't use VS Code

This command should do the trick:

docker compose up --build

Docker will download all the necessary stuff and run the container. If you did everything correctly, bot will connect to the DB, load all the extensions and print Ready at the end. It will also send :peepowave: emoji to the #bot-room if you configured one. You're now all set!


Development

If you didn't run the container in detached mode, just press Ctrl+C to stop it.

Try to tweak some command a little bit and run the bot again, this time in detached mode so it won't block your terminal:

docker compose up --detach

Your changes should be propagated to the server in a moment.

To stop the detached container, use this command:

docker compose down

Local setup (not recommended)

Install the required Python modules (venv / --user flag recommended):

pip3 install -r requirements.txt

Run the bot (might want to use nohup or something):

python3 rubbergod.py

Required/recommended packages (apt)

git
python3.8
python3.8-dev
python3-pip
postgresql
postgresql-contrib
libpq-dev

Contribution

To participate in the development, you need to create a fork and send us your contributions through "Pull requests". You can read more in About forks and Creating a pull request guides directly from GitHub. It may look scary at the first moment, but don't worry, it's actually pretty simple. If you don't know where to start, we can help you on Discord (mentioned below).

pre-commit (useful for contributors)

We use pre-commit for lint check before each commit. Use it by running these commands:

pip install -r requirements-dev.txt
pre-commit install

Authors

Pull requests, issues or tips for new features are very much welcome!

Discord development channel

Got stuck with the above steps? Any questions?

You can discuss bot-related stuff in the #bot-development channel on the BUT FIT Discord server.

Other bots

GrillBot - our 2nd Discord bot almost entirely developed and maintained by @Misha12 aka Hobit.

Pumpkin.py - Highly modular Discord bot created by folks at BUT FEEC.

License

This project is licensed under the GNU GPL v.3 License.

About

FITWIDE discord bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 99.9%
  • Dockerfile 0.1%