RedCokeDevelopment / Teapot.py

A multi-purpose discord.py python discord bot
https://teapot.bot
MIT License
181 stars 32 forks source link

[ENHANCEMENT] Use cogs for commands #46

Open flying-python opened 3 years ago

flying-python commented 3 years ago

https://github.com/RedCokeDevelopment/Teapot.py/blob/f3ba3ff43fbb9ca7d2747935ae6e62fcd28b3910/Teapot.py#L92

Many commands and events in this project does not use cogs. Usage of cogs is recommended. And also don't load commands in on_ready event when you are not using cogs.

The on_ready event may be called multiple times during the execution of the bot. When called multiple times, errors are raised if you load commands in on_ready event.

The Discord API says,

This function is not guaranteed to be the first event called. Likewise, this function is not guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.

Note: You may need to rewrite large portions of this bot to fix this issue. Make sure to test everything works in your cogs before adding them to github.

Sources:

  1. Official discord.py docs: https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready
Dremixbotdev commented 3 years ago

I will open a pull request for this