Coder Social home page Coder Social logo

watcher's Introduction

Watcher

An experimental Hikari Discord bot for assigning active and inactive roles based on member activity

ko-fi

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

Git
Python 3.10+
Poetry

Installing

  1. Clone repository
git clone https://github.com/Myned/watcher.git
  1. Go to project folder
cd watcher
  1. Create a virtual environment and install dependencies
poetry install

Usage

  1. Go to project folder
cd watcher
  1. 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

  1. Setup a bot application at Discord's developer portal
  2. Under General Information, paste APPLICATION ID into config.toml > client
  3. Under Bot, click Add Bot
  4. Under Bot, enable SERVER MEMBERS INTENT (necessary for limbo command)
  5. Under Bot, paste TOKEN into config.toml > token
  6. Under OAuth2 > URL Generator, check SCOPES > bot and BOT PERMISSIONS > Manage Roles and Read Messages/View Channels
  7. 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

  1. Go to project folder
cd watcher
  1. Copy user service file
cp watcher.service ~/.config/systemd/user
  1. Replace user in WorkingDirectory with current user
sed -i "s|\(WorkingDirectory=/home/\)user|\1$(whoami)|" ~/.config/systemd/user/watcher.service
  1. Reload user daemon
systemctl --user daemon-reload
  1. Start and enable service on login
systemctl --user enable --now watcher
  1. Enable lingering to start user services on boot
sudo loginctl enable-linger $(whoami)

Updating

  1. Go to project folder
cd watcher
  1. Pull changes from repository
git pull
  1. Update virtual environment
poetry update
  1. Restart systemd user service
systemctl --user restart watcher

Uninstalling

  1. Stop and disable systemd user service
systemctl --user disable --now watcher
  1. Remove systemd user service file
rm ~/.config/systemd/user/watcher.service
  1. Optionally disable lingering
sudo loginctl disable-linger username
  1. Remove project folder
rm -rf watcher

Contributing

  1. Fork this repository on GitHub
  2. Make changes to the code
  3. Format the code with Black inside the project folder
    poetry run black .
    
  4. Commit the changes to the fork
  5. Create a pull request from the fork

Credits

hikari
hikari-lightbulb
hikari-miru

watcher's People

Contributors

myned avatar xxenocage avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xxenocage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.