Skip to content

internetisgone/kms-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KMS bot

simple discord bot that deletes old messages in text channels on a rolling basis using purge

  • requires the absolute minimum permissions. no message content access
  • purge durations are kept in a local SQLite database and resumed on bot restart
  • pinned messages are left untouched

rest in peace @AutoDelete#6949 which inspired this project

usage

start or reset purge

@kms_bot_user 10d
@kms_bot_user 12h
@kms_bot_user 5m
@kms_bot_user 30s
or any custom duration

stop pruge

@kms_bot_user stop

view channel status

@kms_bot_user status

view all available commands

@kms_bot_user help

setup and run

python 3.8 or higher is required

1. clone this repo

git clone https://github.com/internetisgone/kms-bot.git
cd kms-bot

2. create a bot user

go to discord developer portal and create a new application

in the "bot" section, copy its token and paste it in .env.example, and rename the file to .env. optionally, uncheck "public bot"

in the "OAuth2 - URL generator" section, set scope to bot, and select the send messages, manage messages, and read message history permissions. invite the bot to your server with the link

3. run the bot

create and activate a venv

# macos and linux
python3 -m venv .venv
source .venv/bin/activate

# windows
py -m venv .venv
.venv\Scripts\activate.bat

install requirements

pip install -r requirements.txt

run the bot

# macos and linux
python3 main.py

# windows
py main.py

hosting recommendations

hosting platforms with free tier

  • fly.io. it will build the bot from the Dockerfile. u need to configure a volume for the sqlite db to work
  • pythonanywhere. afaik it has persistent storage but the machine gets restarted quite often

vps self-hosting

(optional) add the bot as a systemd service so it starts automatically on system startup

create a kms.service config file at /etc/systemd/system/

nano /etc/systemd/system/kms.service

the config should look something like this

[Unit]
Description=kms discord bot
After=network-online.target

[Service]
Type=simple
User=[your username here]
Restart=on-failure
WorkingDirectory=/path/to/bot
Environment="PYTHONPATH=$PYTHONPATH:/usr/lib/python[version]/site-packages"
ExecStart=/path/to/bot/.venv/bin/python3 /path/to/bot/main.py

[Install]
WantedBy=multi-user.target

enable and start the service

systemctl enable kms
systemctl start kms

check service status

systemctl status kms

view most recent log

journalctl -u kms -n 50

About

discord bot that deletes old messages on a rolling basis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published