An experimental Hikari Discord bot for assigning active and inactive roles based on member activity
Linux is used for the following commands
WSL can be used to run Linux on Windows, but is not required to run the bot
- Clone repository
git clone https://github.com/Myned/watcher.git
- Go to project folder
cd watcher
- Create a virtual environment and install dependencies
poetry install
- Go to project folder
cd watcher
- Run with optimizations
poetry run python -OO run.py
Run to create config.toml
The file will automatically generate if it does not exist
client = 0 # bot application id
token = "" # bot token
activity = "you" # bot status
db = "watcher.db" # sqlite3 db filepath
guild = 0 # guild id to watch
active = 0 # active role id
inactive = 0 # inactive role id
duration = 0 # time in seconds before considered inactive
- Setup a bot application at Discord's developer portal
- Under General Information, paste
APPLICATION ID
intoconfig.toml
>client
- Under Bot, click
Add Bot
- Under Bot, enable
SERVER MEMBERS INTENT
(necessary for limbo command) - Under Bot, paste
TOKEN
intoconfig.toml
>token
- Under OAuth2 > URL Generator, check
SCOPES
>bot
andBOT PERMISSIONS
>Manage Roles
andRead Messages/View Channels
- Paste generated URL into a browser to invite the bot
Run in the background on most Linux machines
This assumes that the project folder is located at ~/.git/watcher
Change the WorkingDirectory
path in watcher.service
if this is not the case
- Go to project folder
cd watcher
- Copy user service file
cp watcher.service ~/.config/systemd/user
- Replace
user
inWorkingDirectory
with current user
sed -i "s|\(WorkingDirectory=/home/\)user|\1$(whoami)|" ~/.config/systemd/user/watcher.service
- Reload user daemon
systemctl --user daemon-reload
- Start and enable service on login
systemctl --user enable --now watcher
- Enable lingering to start user services on boot
sudo loginctl enable-linger $(whoami)
- Go to project folder
cd watcher
- Pull changes from repository
git pull
- Update virtual environment
poetry update
- Restart systemd user service
systemctl --user restart watcher
- Stop and disable systemd user service
systemctl --user disable --now watcher
- Remove systemd user service file
rm ~/.config/systemd/user/watcher.service
- Optionally disable lingering
sudo loginctl disable-linger username
- Remove project folder
rm -rf watcher
- Fork this repository on GitHub
- Make changes to the code
- Format the code with Black inside the project folder
poetry run black .
- Commit the changes to the fork
- Create a pull request from the fork