Closed developomp closed 1 year ago
Writing proper documentation that tracks what goes where helps a lot, but that is not always feasible especially during rapid development.
We have a website with a guide with lots of information: https://www.sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire
Sapphire will not implement a cog system natively because it completely goes against how Sapphire bots are currently structured. Sapphire's structure is similar to past DiscordJS frameworks like Klasa, Komada, Commando and Akairo. This is to say that this is the structure that JavaScript/TypeScript bot developers have been used to for years and it's only the Python developers who are more used to a cog system.
Because every file (command, listener, precondition, etc) that gets loaded by Sapphire extends "Piece" and pieces in turn are loaded from folders, have paths, and are put into specific "Store"s (ListenerStore, CommandStore, etc) the idea of a cog system is entirely possible. Still, as I said, it won't be natively in Sapphire. That said, you're always free to make your own plugin and after publishing it you can make a PR to https://github.com/sapphiredev/awesome-sapphire to add it to the list.
Adding to the above, it should also be noted that with some work this can already be achieved. Skyra bot used to have an audio cog before we removed audio. You can find the source code here:
https://github.com/skyra-project/skyra/tree/85d3c8c555872bf58a46ecb8502aeeb95ed14143/src/audio
And the commit that removed it, which will also show you how to register this audio
folder: https://github.com/skyra-project/skyra/commit/a96c43f4139ab98b6da5cad3c6847a01dad3f15e#diff-d7f5e1c51b84c90d513c423f1cffc4f1def75b722a1a95ed73b796b6aa9fd2e5L85 (specific line linked)
Is there an existing issue or pull request for this?
Feature description
When developing complex bot, it is common to see one feature being fragmented across multiple files. This leads to terrible DX.
Desired solution
A new folder named cogs containing either files or directories that exports a cog class with listeners, application command registers, and all the good stuff.
File system tree example:
Alternatives considered
Writing proper documentation that tracks what goes where helps a lot, but that is not always feasible especially during rapid development.
Additional context
This is inspired by discord.py's Cog system: https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html