mirror of
https://github.com/myned/watcher.git
synced 2025-12-05 22:05:45 +00:00
Discord bot for activity roles
|
|
||
|---|---|---|
| commands | ||
| tasks | ||
| tools | ||
| .gitignore | ||
| config.py | ||
| LICENSE | ||
| poetry.toml | ||
| pyproject.toml | ||
| README.md | ||
| run.py | ||
| watcher.service | ||
Watcher
An experimental Hikari Discord bot for assigning active and inactive roles based on member activity
Prerequisites
Linux is used for the following commands
WSL can be used to run Linux on Windows, but is not required to run the bot
Requirements
Installing
- 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
Usage
- Go to project folder
cd watcher
- Run with optimizations
poetry run python -OO run.py
Setup
Starting
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
Inviting
- Setup a bot application at Discord's developer portal
- Under General Information, paste
APPLICATION IDintoconfig.toml>client - Under Bot, click
Add Bot - Under Bot, enable
SERVER MEMBERS INTENT(necessary for limbo command) - Under Bot, paste
TOKENintoconfig.toml>token - Under OAuth2 > URL Generator, check
SCOPES>botandBOT PERMISSIONS>Manage RolesandRead Messages/View Channels - Paste generated URL into a browser to invite the bot
systemd service
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
userinWorkingDirectorywith 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)
Updating
- 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
Uninstalling
- 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
Contributing
- 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