SocksTheWolf / AntiScamBot

A discord bot that shares commission scammer ban lists
https://scamguard.app/
MIT License
5 stars 3 forks source link

Bot code restructuring suggestion #53

Open user4752 opened 2 months ago

user4752 commented 2 months ago

After hearing you state you wished to reorganize the code, I was reminded of a feature discordjs has and read up on the docs for discordpy and was happy to find out it does also implement a similar feature.

Discordpy extensions allow separating out sections of code into sub-modules as you had indicated you thought about doing, and allow for hot reloading and loading of new code without needing to shut the bot down in order to do so (assuming the main bot process has been coded in a sufficient manner to allow this)

Discordpy cogs allow grouping of functions into a shared class space inside of modules which provide skeleton for a framework to run commands and bind listeners to event emitted from the discord api.

Cogs can be the basis for organizing of slash commands into groups. Cogs would also simplify parameter passing between classes and functions as cogs classes can be referenced externally via the get_cog() function call.

SocksTheWolf commented 1 month ago

That could be kinda nice, BotMain is getting really bloated with the number of base class references it currently has. I would love to see it more lean if possible.

user4752 commented 1 month ago

Once #55 has been reviewed discussion on how commands can be logically organized can occur in order to further development in this idea.

I have created a sample bot using extensions and cogs have found they're extremely easy to setup, deciding on how to group commands is the difficult part.

Next steps on testing for me are