Base Cog Class #2151
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot#2151
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This issue aims to provide information about why I plan on introducing a base cog class to Red. Some people have already noticed its inclusion in #2149, and rightly suspect it's a breaking change they will need to adjust for going forwards.
We've never really needed a base cog class up until now, because we tend to describe the settings and properties of particular cogs in a proxy-like style, rather than attach these settings and properties directly to the cog object. We haven't needed many settings pertaining to specific cogs, so this usage has served us fine. However, #2149 proposes using a different approach - modifying and retrieving properties of a cog during runtime through a direct API to the cog object, similar to how
Commandobjects are used. In fact, thePermissionscog draws some new similarities between how we treat cogs andCommandobjects.As always with significant structural changes like these, I imagine we will find many usages going forward for this base cog object which greatly simplify some problems, which would be otherwise quite complex to solve. It's an incredibly simple change for the cog creator to incorporate, whilst potentially adding lots of freedom for us developers to add new functionality to all cogs.
Now, as for semantic details: the new base cog class will be located at
redbot.core.commands.Cog; so incorporating this change won't even involve an extra import.As a transitional measure, you can do this to prepare for the new base cog class:
You may call
super().__init__()if you'd like, but if you don't, it will be done for you inbot.add_coganyway (Disregard this sentence if you don't understand).The following attributes as added in #2149 will be reserved for cogs, so please don't have any attributes or methods with these names, or things will break!
requiresall_commandsallow_fordeny_toclear_rule_forset_default_rulereevaluate_rules_forOther than making the permissions cog play better with cogs, what other benefits (either now or in the future) can cog creators expect from inheriting this base class?
What other functions will the base class Have? One function I can see it having is allowing a master config file that can be used for many cogs and not tied to a specific one ?
@Redjumpman @useruser3 I don't plan on polluting this class with methods and attributes or try to provide a plethora of functionality to it, however I'm sure in the future it will make solving complicated problems quite simple for us maintainers. Just look at how
redbot.core.commandsturned out - initially we only needed that for i18n on command help, but looking back, it's hard to know what we would have done without it.For now, you get the
all_commandsproperty, which returns a dict mapping command names to commands which come from that cog 😃 I don't have any specific plans otherwise. There's a possibility that in the future it'll allow the use of check decorators like@checks.is_owner()on cogs to apply that check to every command from that cog.Closing now that the base cog class has been merged.