First Time Setup
Updated as of sonnet V2.0.2-1Part 1: Getting it all Installed
1.1: Python
1.2: Cloning + Base Dependencies
1.3: Extra Dependencies
- Install
mariadb connector/C
from your package manager - Have a mariadb server set up inside your linux machine, if you are using a network attached server you will have to make the sonnet user manually
- Use
python3 -m pip install mariadb
to install the mariadb connector/Python library - Use the mariadb-migrator-py script from the sonnet-discord github organization to INITDB, it will spit out a
.login-info.txt
file, put that in the sonnet root dir - Install google-re2, this may be called libre2 or libre2-dev depending on the distros package manager
- Use
python3 -m pip install pybind11
to install pybind, this is a compile time dependency of google-re2 - Use
python3 -m pip install google-re2
, if this fails it means your version of re2 is out of date (this is the case on Ubuntu LTS 20.04 repos), in which case you must compile re2 from source to use it
This guide will assume you are using a debian based distribution, and provides "common issues support" specifically for Ubuntu LTS, if you are not confident with Linux it is strongly recommended to use the latest Ubuntu LTS version to install Sonnet (as of writing this is Ubuntu 22.04)
If you are using Ubuntu and this is a fresh install, start by running sudo apt update; sudo apt upgrade
and follow prompts to update packages, this avoids most problems of out of sync packages causing issues
To start off you will need python 3.8 or greater installed (In the near future this will become 3.10 or greater, I do not recommend doing a 3.8 or 3.9 install)
This can be done via sudo apt install python3
for debian based distributions, if you are not using a debian based distro then use the appropriate package manager, if you are not using sudo in favor of something like doas then understand this guide is made for people who barely even know what sudo is
Make sure that the version installed will work by running python3 --version
if it isn't a high enough version install python from a different source
Once python is installed you can move on to installing sonnet itself, this can be done with git clone https://github.com/sonnet-discord/sonnet-py
If you get a error that git is not installed, refer to your package manager command to install git
After installing sonnet, move into the sonnet directory, assuming you just git cloned it that should be possible with cd ./sonnet-py
Now install sonnets dependencies with python3 -m pip install -r requirements.txt
If you get an error that python3 is not found, but you installed python, then try replacing python3
with python
, do this for the rest of the guide, if it still errors then ensure python is actually installed
mariadb (please don't) (abstract guide)
Why not: mariadb has a complicated process to install, doesnt support as much common sql as sqlite3, and has higher latency than sqlite3, unless you have a reason to you should just use sqlite3
If you are planning on using mariadb over sqlite3 then there are extra steps involved to installing mariadb:
re2 (please do) (abstract guide)
Why yes: re2 is more secure than the competing library, re, this is due to re being turing complete, leaving room for exploit attacks on the bots regex parser if allowed on insecure guilds, if you are hosting a public instance you absolutely must use re2 for security
If you are planning on using re2 over re there are some extra steps you must complete
Part 2: Configuring Sonnet
2.1: sonnet_cfg.py
2.2: LeXdPyK_conf.py
2.3: Optional sonnet-modules
Once sonnet has been installed it is time to configure the bot, if a config is not defined it will become its default
Conf Name | Type | Default | Description |
---|---|---|---|
GLOBAL_PREFIX | str | ! | Default global prefix, can be set per server |
BLACKLIST_ACTION | str(warn|mute|kick|ban) | warn | Default action to occur when someone breaks blacklist, can be set per server |
STARBOARD_EMOJI | str | ⭐ | Default emoji to use for starboard, can be set per server |
STARBOARD_COUNT | int|str | 5 | Default starboard reaction threshhold, can be set per server |
DB_TYPE | str(mariadb|sqlite3) | mariadb | Choose between using mariadb or sqlite3 |
SQLITE3_LOCATION | str | datastore/sonnetdb.db | If using sqlite3, the location where the database will go |
REGEX_VERSION | str(re|re2) | re2 | Configure whether to use re2 or re, any public instance must use re2 due to exploits, however re is cross platform and easier to set up |
CLIB_LOAD | bool | True | Configure whether or not to compile and run the c loader, this requires gcc and make to be installed |
GOLIB_LOAD | bool | True | Configure whether or not to compile and run the go loader, this requires go and make to be installed |
GOLIB_VERSION | str | go | Configure the go binary to attempt to run when compiling go code, this can be ignored unless you want a sepcific go version |
BOT_NAME | str | Sonnet | Configure the name that the bot will refer to itself as, instead of sonnet |
STATELESS | bool | False | Configure whether the bot should run in stateless mode, which disables process local caching of the database, only turn this option on if you are running Sonnet on a shared database |
AUTOMOD_ENABLED | bool | True | Globally enable or disable all automod functionality (all blacklists, all notifiers), disabling this may be handy if you are performing a non moderation focused install |
After configuring sonnet you must configure the bot owner(s)
the BOT_OWNER variable can be either strings of or ints in a list, or can just be one string or int
A normal single user install might look like BOT_OWNER = 123456789
, while a multi user install might look like BOT_OWNER = [23423, 354345]
If you want more features out of sonnet you can grab them off the sonnet-modules repo
git clone https://github.com/sonnet-discord/sonnet-modules
in the same dir you were in when you git cloned sonnet, and use modmanager.py to install custom modules easily
An example is installing ultrabear/usertrust for the usertrust system, enter the sonnet-modules directory with cd ./sonnet-modules
and run python modmanager.py -S ultrabear/usertrust
, assuming sonnet-py is in the same directory it will automatically install, use python modmanager.py -R ultrabear/usertrust
to uninstall the module
Part 3: Starting sonnet
3.1: Getting a bot token
3.2: Putting your token in sonnet
- Using env var SONNET_TOKEN: Set SONNET_TOKEN to the discord token
- Using env var RHEA_TOKEN: Set RHEA_TOKEN to the discord token, this is kept for backwards compatibility with rhea, sonnets predecesor
- Using encryptboot: start sonnet with the --generate-token flag, it will ask for the token and a password, on next boot do not put --generate-token, it will ask for the password and read from an encrypted token file named
.tokenfile
3.3: Starting sonnet
Go to https://discord.com/developers/ and obtain a bot token, the specifics of that is out of the scope of this guide, so I will trust you figured it out somehow
There are 3 options to chose from when putting your token into sonnet:
Everything is installed and configured, your discord token is set, it is now time to boot sonnet
Run python3 main.py
, if sonnet booted sucessfully then congratulations, you now have a sonnet instance
If something breaks, try and read the error and look back to make sure you did not skip a step
Enjoy sonnet, and enjoy modularity
-- Ultrabear