Cog Actions

So, my bot is running the cog-like system. However, I was wondering if there was a way to run actions on the entire cog. For example: Unloading the cog Loading the cog Reloading the cog (at runtime, through a command, and not just commenting things out and such) Apologies if I missed something in the guide that stated how to do this.
Solution:
first of all I will assume you followed https://www.sapphirejs.dev/docs/Guide/additional-information/implenenting-a-discordpy-like-cog-system If you did then just like how you call register you can also call deregisgter https://www.sapphirejs.dev/docs/Documentation/api-pieces/classes/StoreRegistry#deregister Alternatively you can loop through all the stores held in the particular StoreRegistry (cog) and call store.unloadAll()...
Sapphire Framework
Implementing a discord.py like Cog system | Sapphire
Developer who come from the Python ecosystem may be familiar with the "[Cog]" system that discord.py has implemented.
Jump to solution
4 Replies
Solution
Favna
Favna2y ago
first of all I will assume you followed https://www.sapphirejs.dev/docs/Guide/additional-information/implenenting-a-discordpy-like-cog-system If you did then just like how you call register you can also call deregisgter https://www.sapphirejs.dev/docs/Documentation/api-pieces/classes/StoreRegistry#deregister Alternatively you can loop through all the stores held in the particular StoreRegistry (cog) and call store.unloadAll()
Sapphire Framework
Implementing a discord.py like Cog system | Sapphire
Developer who come from the Python ecosystem may be familiar with the "[Cog]" system that discord.py has implemented.
i dont know
i dont knowOP2y ago
Thank you!
Favna
Favna2y ago
I should mention that if you go the deregister route and this is a dynamic process then you should reference the source code of @sapphire/pieces (the docs link to it under "defined in") for re-registering and call similar code. Seeing as before you would've used registerPath I'm not 100% sure if flipping deregister and register with work OOTB but it's definitely possible. You'll just have to leverage some of the more internal-ish methods. which uh... is kind of a fact for a cog like system anyway
i dont know
i dont knowOP2y ago
I guess I'll try it out and get back to you. Once again, thank you for your time <a:TE_bowOwO:992357122631282749>
Want results from more Discord servers?
Add your server