New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce subfolders into the cog folder so that we can organize the cogs better. #160
Comments
Comment from Johannes Christ: I disagree heavily! Every cog should do one thing, and do that thing well. Grouping together too many commands in one cog will make it harder to maintain, and in addition to that, it makes it harder to find commands. To support my argumentation - Without looking at the source code, and trying to put yourself in the shoes of a new contributor, answer the following questions: Where does the code block sanitizer live?In theBot cog. In my opinion, the bot cog should contain commands related to the bot, and this should be in its own cog.
Which cog handles the subscription to announcements?TheVerification cog. This makes no sense to me at all. The only reason that this has a place there might be because it is mentioned in the doc string, but that still doesn't make it a valid spot in my opinion. If anything, we should create an extra cog, named Notifications or similar, which we could also expand later to allow subscribing to other things than regular announcements, if applicable.
Which cog updates users on the website?TheEvents cog. This makes no sense to me - the name implies it's handling general events. It currently handles command errors, and that event. This doesn't have any place there. This is not something general, and, in my opinion, should be factored out to another cog, e.g. UserUpdater .
In addition to that, the cog name currently makes it sound like it handles all events. That is not the case.
A couple other concerns:
As another example, in my bot, every command is its own file. This is very simple to work on, compared to e.g. the Snake cog. |
Comment from Leon Sandøy: you've made many fine arguments towards why we shouldn't do my first suggestion, and I buy them. What about my second suggestion? |
Comment from Johannes Christ: My bad, I have not read that yet. |
Comment from Leon Sandøy: maybe you're used to it since you have "one cog for each command", which sounds absolutely insane to me. With the clean cog I'm working on, we'll have 22 cogs. I think when you have 22 files in a folder, it's time to start making subfolders. anyone else have an opinion? could it really hurt to be more organized? |
Comment from Kingsley McDonald: i believe that subfolders is the way to go. i like the unix philosophy, in which the following is stated:
|
Comment from Leon Sandøy: after volcyys 2000 word writeup, I agree that folders seems like the better option. he makes a bunch of valid points about separation and I agree with all of them. I do think the need for those folders is there already, though. |
Comment from Johannes Christ: mentioned in merge request !29 |
So what's still outstanding from this discussion. It seems like consolidation was agreed against, while adding some more structure to the cogs folder was agreed upon? |
I think that this can wait for us to split up the bots and then we can re-evaluate which bots may need their cogs organising even more than that. |
We're not doing the splitting up the bots thing after all, it seems. So we can probably go ahead and do this. |
I had a good think about this and sensible ways of dishing up some of the current files into subfolders.
An easy way to implement this in both the help command and reloading of cogs?
A few ways this could be used:
|
@MarkKoz and I recently defined groups for the current bot functionality in order to define easy enough to understand We settled with the following: Filters
Information
Moderation
Utility
While we've listed the extensions like that currently, we are going to refine the structure of the extensions themselves where appropriate to make it as logical as possible. For example, Extensions like |
This list isn't final even though I'm pretty happy with it personally. Feel
free to comment if you have any suggestion improvements or changes to it.
Furthermore, I think we should take the opportunity to rename the `cogs`
subpackage to `extensions` or probably the shorter, and likely better,
`exts`.
|
definitely agree |
I think we're waiting for the PRs to clear up before implementing this to avoid many conflicts. Besides that, there's nothing really else stopping it. I am happy with the discussion and conclusion reached for the directory structure. |
@MarkKoz Any specific PRs we're waiting for? I feel like this is gonna cause conflicts no matter when we do it, because we're never gonna have 0 PRs. Also, I like the suggested subfolders. I'm not sure I like |
No, not really. Perhaps the help channel system. Anyway, I can just take responsibility for resolving conflicts on all PRs myself.
In a sense, "extensions" is more correct since the package contains modules which Discord considers extensions. In turn the extensions contain the cogs. So the package contains extensions, not cogs. That was the original line of thinking. However, in retrospect "cogs" is not so bad nor is it really incorrect. The package does contain cogs, just not directly. That being said, seasonalbot has switched to "exts". Should this repo should mimic it anyway? |
My idea for the new directory layout that applies Scragly's sorting:
I didn't included every category currently, but this should how I see this. |
@MarkKoz alright, and besides your argument about how it's technically more correct to use extensions than cogs, it also makes it clearer to users unfamiliar with the term cog and with discord.py what the folder contains. consistency with seasonalbot would be nice, I guess. I'm just generally allergic to abbreviated names for things. I think |
hmm, these imports with |
@lemonsaurus discord.py have |
Hey, yea I decided to go with As @ks129 notes, d.py uses the terminology although they drop the plurality. I personally think it's better in plural, but I suppose that's a very personal preference. |
in plural it's less ambiguous - |
I agree with @lemonsaurus. My preference would have been |
About |
Within |
Here's what I currently have:
I'm not satisfied with the name for the Each sub-package could be treated as an extension, but this limits control over which cogs are loaded. On the other hand, if each module is an extension, it's difficult to distinguish normal modules from extensions without at least importing them. This is relevant for the functionality of the extension load, unload, and reload commands. Which way should we go with? Perhaps each module could also be an extension. The sub-packages could be "meta extensions" that load the extensions within them. |
I just had this thought earlier today and wanted to comment here, but I see you've already been thinking about this. I've been finding it a little awkward to not be able to reload a specific cog in the moderation package, for example, and wanted to propose that each cog is its own extension to alleviate this. The inability to unload a specific cog while keeping others intact seems like a much bigger problem, although one that we haven't run into yet. However, you're also raising some good points about non-extension modules. Perhaps they could just be nested further into a |
We effectively manually maintain a list of extensions when we load them in This avoids any complicated extension detection code at the cost of being vulnerable to contributors forgetting to update the list. However, that doesn't seem like a valid concern since forgetting to load the extension would be a very obvious error to catch; it hasn't been a problem so far.
This would be OK when there are many modules, but would just feel clumsy if there's one or two. I don't completely hate the idea, but I want to keep exploring other solutions, such as my above proposal. |
New idea: prefix names of non-extension modules with an underscore. |
Originally posted by Leon Sandøy:
We should consider either consolidating similar cogs into a single cog with more features (like an Admin cog that had big brother, clean features, and defcon), or to create subfolders in the cogs folder so we can at least group the similar cogs together. The folder is growing unruly.
The text was updated successfully, but these errors were encountered: