-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
- Discord Developer Portal
- Configure the bot .env
- Configure the RoleBot menu.json
- Running the bot in Docker
- Running the bot in Kubernetes
- Running the bot locally
- Build from source
One of the first steps to do before you even get started:
- Login to the Discord Developer Portal.
- Create an Application.
- Inside the Application, create a Bot.
- Save the
token. - Give your bot a
nameandprofile picture. - This bot will require all
Privileged Gateway Intents, activate all three:PresenceServer MembersMessage Content
- Go to the OAuth2 -> URL Generator.
- Check the box for scopes:
bot. - Check boxes for the following
Bot Permissions:-
Manage Roles(used by AutoRole and SelfRole) -
Manage Channels(used by Commands, AutoScale and SelfRole) -
Read Messages/View Channels(used by Commands and SelfRole) -
Moderate Members(used by AutoRole and SelfRole) -
Send Messages(used by Commands) -
Manage Messages(used by Commands) -
Embed Links(used by Commands) -
Attach Files(used by Commands) -
Read Message History(used by Commands) -
Mention Everyone(used by Commands, Optional)
-
- Copy the
Generated URL - Go to the URL and assign the bot to your Discord Server.
The endpoint for the bot should now show up in your Discord server as offline.
This bot's configuration is .ENV based. That means every setting is to be configured through environment variables. Doing this enables having a single container image for every installation in the world as the settings are injected from the outside.
Please note, there are two locations that this bot can look at for its configuration. This however, depends on what type of deployment you have chosen.
- For Docker: Place the .env file in the top level, next to the docker-compose.yml and Dockerfile. So that's
./.env. - If running the bot locally: Place the .env file in the bot's data folder. So that's
./clanbotjas/data/.env.
# General Bot settings
# BOT Login Token
BOT_TOKEN = NjY1OTAyNzgxxjQ0MqQzOTg4.G-LXwZ.ih6o6tU98nFNnFgKX4XxF5j9g9CiTjFG1vbIuE
# ID of your Discord Server/Guild
GUILD_ID = 765804631873189936
# ID of the text channel where the bot sends logs
LOG_CHANNEL = 976204250007162414
# User permission settings
# ID for the role required to execute slash commands (full permissions)
COMMAND_PERMISSION_ROLE = 967855625404444589
# Voice Auto Scaler settings
# Enable or Disable Voice Auto Scaler, true/false
VOICE_SCALER_ENABLE = true
# ID of the category to auto scale voice channels in
VOICE_CHANNEL_CATEGORY = 886364798749848896
# Default name for auto scaling voice channels
VOICE_CHANNEL_DEFAULT_NAME = 'Voice Channel'
# Self-Role text channel subscription settings
# Enable or Disable Self-Role channel subscriptions, true/false
ROLEBOT_ENABLE = true
# ID of the text channel where subscription options should appear
ROLEBOT_SETTINGS_CHANNEL = 885965370068838858
# Auto-Role settings
# Enable or Disable Auto-Role, true/false
AUTO_ROLE_ENABLE = true
# Roles to instantly add to new members joining the server, comma separated
AUTO_ROLES = Enrolled,Fun,tf2
# Poll settings
# Enable or Disable Polls, true/false
POLL_ENABLE = false
# We have supplied the Helvetica font, please provide your own in the data folder if you wish. (TrueType/.ttf only!)
# Font Regular (default = Helvetica.ttf)
POLL_FONT_REGULAR = Helvetica.ttf
# Font Bold (default = Helvetica-Bold-Font.ttf)
POLL_FONT_BOLD = Helvetica-Bold-Font.ttf
# If fonts other than the default are used, scaling might be required. (default = 10)
POLL_FONT_SCALE = 10The bot requires a configuration file (JSON) to know which role is bound to which text-channel. We've supplied an example in ./clanbotjas/data/menu.json.example.
Note, if you are running with the container option, please populate this file in the container's volume before starting the bot.
- The first level defines the Catergories where text-channels are in.
- The second level defines the text-channels and their roles within the category.
In the example we have two categories, Games and Chatrooms. Each category has two channels joined by a role. If any of these channels and/or roles don't exist when the bot is started, they will be automatically created. Further administration can be done from within Discord and will be saved to menu.json by the bot.
Please keep in mind that these names must follow the same rules as the Discord client follows, so no spaces for titles/role names and no upper-case for titles. Roles can use upper-case. Category titles can use both upper- and lower-case and will be converted by the Discord client to all upper-case, however, the backend is still case-sensitive based on the actual input!
[
{
"title": "Games",
"channels": [
{
"title": "team-fortress-2",
"role": "tf2"
},
{
"title": "pubg",
"role": "pubg"
}
]
},
{
"title": "Chatrooms",
"channels": [
{
"title": "announcements",
"role": "announcements"
},
{
"title": "general",
"role": "general"
},
{
"title": "offtopic",
"role": "offtopic"
}
]
}
]We've chosen to use Docker Compose to manage the settings and runtime of the container. All you really need to get started and run the bot are the following files from the repository:
- docker-compose.yml
- .env.example
- files inside clanbotjas/data/
- Edit the
docker-compose.ymlfile and make sure to replace/opt/discord/ClanBotJas/clanbotjas/data:/clanbotjas/datawith/your/path/to/data:clanbotjas/data - Rename
.env.exampleto.envand keep it in the same folder as thedocker-compose.yml - Configure the bot with your values in the
.envfile.
If you are having trouble finding ID's of all objects, enable Developer mode in Discord. This will allow you to right click -> Copy ID on all objects.
- Rename
menu.json.exampletomenu.json. - Replace the sample entries with your own categories, channels and roles.
- Copy/Move the eveything from the
clanbotjas/datafolder into the path you configured in step 1. - Run
docker-compose up -dfrom the commandline in the same folder yourdocker-compose.ymland.envreside. - The bot should now be online in your Discord server!
If you are running a Kubernetes cluster, we've supplied some example files in the repository under the folder kubernetes. You will need te following files from the repo to deploy to Kubernetes:
- files inside the kubernetes folder
- files inside clanbotjas/data/
- Go into the Kubernetes folder, you will find 4 yaml files.
- Open
clanbotjas-env.yaml. - This file creates the configMap for the application, replace all values and save.
If you are having trouble finding ID's of all objects, enable Developer mode in Discord. This will allow you to right click -> Copy ID on all objects.
- Open
clanbotjas-pv.yaml. - In the example, we use an NFS server for persistent storage. Please replace this with your own storage provider if necessary.
- If you are using NFS, replace the path:
/mnt/path/to/clanbotjaswith your own NFS folder mount location. - Also make sure to enter your NFS server address.
- Go to the
clanbotjas/data/folder and renamemenu.json.exampletomenu.json. - Replace the sample entries with your own categories, channels and roles.
- Copy all files from the
clanbotjas/datafolder into the Kubernetes volume location. - (Optional) create a new namespace if you want to.
kubectl create namespace <name> - Apply the
kubernetesfolder.kubectl apply -f kubernetes -n yournamespace - The bot should now be online in your Discord server!
It's also possible to run the bot as a standalone Python application on your computer. Make sure you have Python 3.9 or later installed.
- Run
git clone https://github.com/ClanBadJas/ClanBotJas.gitfrom the location you want to run the bot. - cd into the
clanbotjasfolder and runpip install -r requirements.txtto install the dependencies. - Configure the bot settings in
clanbotjas/data/.env, you can copy the.env.exampleto.envto make it easy.
If you are having trouble finding ID's of all objects, enable Developer mode in Discord. This will allow you to right click -> Copy ID on all objects.
- Rename
menu.json.exampletomenu.jsonin the same folder. - Replace the sample entries with your own categories, channels and roles.
- Start the bot using
python cogmanager.py - The bot should now be online in your Discord server!
If you want to build the container from source, follow these steps:
- Run
git clone https://github.com/ClanBadJas/ClanBotJas.gitto download the repository. - Make sure you are in the root of the project.
- Run
docker build -t <username>/<repository>:[version] .to build the container, dont'forget the trailing dot. - The image is now ready to be pushed or used locally.