Skip to content

Code for Sentdebot in the Sentdex discord channel (discord.gg/sentdex)

Notifications You must be signed in to change notification settings

Matesxs/sentdebot

 
 

Repository files navigation

Sentdebot V2

Rework of original Setdebot to more modular form and using modern discord API.
Except of reimplementing all the original features of the bot this bot implements some more features that will be described later.

Table of contents

General info

Discord bot created in python using disnake library Link.
This project is no replacement for original Sentdebot. It was created only as programming practice and fun so there was no consultation between authors and original bot and me and because of this some features are implemented in my way and not exactly like in original bot and the code is not very clean. Because original bot was ment to be used only for one specific server and some features are tightly related to it then this bot to share similar behaviour and simply some functions will be unavailable if invited to different guild for which was the bot configured.

Bot structure

Main difference between this bot and the original one is the that this bot is split to modules with different subfunctions to be as modular as possible.
This bot is divided to few main parts: main bot file, cogs, config, database, features, modals, static data and utils. 
Main bot file (sentdebot.py in root directory) is used as entrypoint of whole bot. 
Cogs is folder to store individual extensions of functionality. 
Config stores parser for configuration files and definitions for cooldowns, there is also template for configuration file that you want to copy, modify and rename to ``config.toml`` to be able to run this bot. \
Features is used to store extension of disnake functionality by wrappers, custom functional components and other things. 
Modals stores discord UI definitions for InApp forms. 
Static data folder is used to data that are not change in runtime, and it's desired to have them on one place to better access for editing. 
Utils is place for any other extensions, helper functions, etc.

Features

  1. Buildin robust error handling with option to log to file and log discord channel (in cases that are forgotten to handle or caused by bad manipulation of user)
    1
  2. Managing system for loading, unloading and reloading extensions on the fly
  3. Guild statistics collector and displayer
    2
  4. Parametric random role giver
  5. Custom help command with automatically generated help for individual message commands
    Help embed is send with button to list through help pages that outly author can control
    3
  6. System for managing help requests in help channel using threads and ticket system
    Help channel is locked by default to not allow users to write here directly, instead help requests are created using command that will bring this help request form.
    7
    Help request is then created in help channel as thread by the bot and author is invited to that thread, this request is added to database too to track time of last activity.
    8
    If then problem is solved user or mod can call /help_request solve in this thread to mark it as solved and lock it from future messages.
    9
  7. Extension for storing project and information about them
    Mods can add projects using this form (ofcourse there is command to remove them too).
    4
    User then can find project using command /projects get <name> and bot will show you all current projects as reference.
    5
    And bot will then send information about the project in this form
    6
  8. Simple code evaluator for almost any language
    10
  9. Bookmark feature, so you don't lose some important messages
    User can create bookmark of any message reacting to it by 🔖 or using rightclick on message -> Apps -> Bookmark
    Bot will then send to users bookmark like this
    11
  10. Basic Q&A system to answer users repeating questions based on Levenshtein distance
  11. Audit log to log inportant actions of users for admin purpose with automatic clearing of old entries
  12. Warden extension to monitor spam in channels and report duplicate messages
  13. Robust database using SQLAlchemy ORM
  14. Centralized handling of added reaction because there is needed some more processing for non cached messages

And many other smaller things

Deployment

Without any container (python version >= 3.8)

pip install -r requirements.txt
python sentdebot.py

Using docker compose

docker-compose up --build -d

# After code modification rebuild using
docker restart sentdebot
# Or when you need some new packages installed
docker-compose down
docker-compose up --build -d

## Special cleanup cases ##
# Teardown and remove volumes
docker-compose down -v

# Teardown and remove image
docker-compose down --rmi local

# Complete cleanup
docker-compose down -v --rmi local

# Dump of database
docker exec -t sentdebot-db pg_dumpall -c -U postgres > database_dump.sql

# Restore database from dump
cat database_dump.sql | docker exec -i sentdebot-db psql -U postgres

Using Heroku hosting only push to heroku project repository or link it to your copy of this repository

Any other deployment methods are up to you

About

Code for Sentdebot in the Sentdex discord channel (discord.gg/sentdex)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.8%
  • Other 0.2%