Self-Hosting Guide

Written the best I can, so you know I mean quality. /s

Windows

Just because you can run Invitebot on Windows, doesn't mean you should. And even though you are welcome to ask, as I don't advise running it on Windows I may not provide support for running it on there.

If you really want to run InviteBot on Windows, install Python from Python's website. Then, continue the tutorial in Windows's Terminal (I advise PowerShell but old cmd.exe might also work)

Notes:

  • Screen won't work on Windows, and you can't run ./start.sh as it's a shell, not a batch script. You need to run python3 bot.py for starting the bot.
  • It depends on the version of Invitebot you are using, but newer ones will have an ability to download blank config files and language packages through my servers. This will (probably) not work on Windows.

1. Getting the Bot

Open the terminal you use, and then run the command

git clone https://github.com/Nevalicjus/invitebot.git

You'll also need python, which you can get by running one of the commands below, depending on your operating system:

Installing Python

sudo apt install python3-pip
sudo pacman -S python-pip
brew install python3-pip

Additional Installaiton steps might apply

dnf - Fedora / CentOS / RHEL

sudo dnf install python3-pip python3-wheel

yum - CentOS / RHEL

sudo yum install python34u python39u-wheel

Installing Python

sudo zypper install python3-pip python3-setuptools python3-wheel

and the discord.py library, which you can get by running this command:

python3 -m pip install discord.py

2. Setting up the Bot

You probably need to head to the Discord Developer Website to create an application, and the in the application create a bot. Your bot application has to have the Members Intent enabled. On the same page, you can find the token, which you'll need to copy.

Head to the main-config.json file, in which fill the DiscordToken space with the token you copied. I'd also advise to add your ID in the OwnerUsers space.

If you are fine with other settings, save the file and start the bot. You can use

python3 bot.py

in your terminal, or combined with the screen command to make the bot as a separate 'escapable' process (escapable when you use ctrl+a and ctrl+d, you can come back to it by using screen -r if it's the only thing you use screen for, or screen -ls to get the screen's id, and then screen -r <screen id> to attach back to the bot's screen)

screen python3 bot.py

You can also use the start.sh file I've provided, that uses the screen -S invbot python3 bot.py to create the screen for you. You'll want to use

./start.sh

to run said script, or chmod +x start.sh beforehand to make the file an executable and then run it. The -S invbot makes your screen titled, so you can then use screen -r invbot if you use screen for more than just the bot.

3. Adding the bot

You'll probably want to add the bot to a server now.

You can generate the invite link in the OAuth2 tab on the Discord Developer Website. In the scopes tab select bot, and then in the Bot Permissions tab select:

- Manage Server
- Manage Roles
- Manage Channels
- Create Invite
- View Audit Log
- Read Messages
- Send Messages
- Embed Links
- Attach Files
- Add Reactions
(weight 268487921)

If you want to give it 'minimal permissions', or just the Administrator permission (weight 8) (probably safe, you are hosting the bot not a 3rd party)

When you then use the link, you should see the files with id's of servers your bot joined appear in the configs/ folder.

Then, you can use the bot's commands to setup your invites. Other setup options are best described in the other parts of this documentation, or just in the help command.


Desync

If the bot falls out of sync with uses for certain invite, he should correct himself on the next member - member x - but remember, then the member x can have a misgiven role (this should only happen if the bot has been offline during member joins)

Logging

If you enable logging, config[ServerLog], which isn't enabled on default, the bot will log some of his actions onto a discord channel. The bot also prints it's actions on the console, and writes them to a main-config[LogFle], so you can view them later


If you need to contact me, you can find me on the Support Server or message me on Twitter - sorry if I won't reply fast.

Great thanks to Piotr Młynarski for the first version of the algorithm


Last update: 2023-01-05