jack3898 / discord-youtube-bot-2

A powerful Discord YouTube Bot.
0 stars 0 forks source link

Tidy events #3

Open jack3898 opened 2 years ago

jack3898 commented 2 years ago

Currently events are all over the place.

The reason this is is because events can be a pain to manage. When someone invokes a command, it's easy to create a new event which can cause event pollution.

Currently, this isn't a problem as events do seem to be managed, but I would like a consistent solution in place.

One example is in YouTube interface.runner(), events are removed for each new song. What if someone else wants to register the same event somewhere else? It'll be removed.

Maybe a new class to hold existing events for guilds. A function only needs to be registered once. The class can then handle creating an event, and manage event pollution on its own. I think this would be the best way.

Or, do what is currently done in the MediaControls class which is to register the events on the construction of the class using a callback. As one class should only ever be construed per guild, this restricts the creation of the event to one per guild.