codinglab-io / discord-bot

Discord bot for Codinglab's server.
https://discord.com/invite/codinglab-174169014568878080
MIT License
19 stars 14 forks source link

refactor: modularize commands and handlers #48

Closed neolectron closed 1 year ago

neolectron commented 1 year ago

Problem

With the architecture we have right now, commands and events-handlers aren't self-contained, the amount of changes necessary to add a feature was too high, and too spread-out in multiple files.

Solution

By making a module system, we allow everyone to create features in a more standardized way. The cost to migrate a feature to the new module system is still very-low as we shouldn't have any blackboxing. It is still possible to map any handler to any event.

Drawbacks

Each module have to be aware of other modules in order to prevent their execution if another one is doing something related.

ex:

if we post a link in #cool-link and it contains a pattern to replace (vxtwitter), the bot will try to replace/remove the message and add the reactions at the same time.