[WIP] [V3] Cog-specific command mapping #2144
No reviewers
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 milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!2144
Loading…
Reference in a new issue
No description provided.
Delete branch "V3/feature/cog-command-map"
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?
DO NOT MERGE - WORK IN PROGRESS
and also because my code is terrible
This PR only has the framework for this to function so far. I am currently working on refactoring CustomCommands and Alias to take advantage of the framework currently in this PR.
I've decided to open it early so I could get feedback and discuss the changes as they're done, and to mark this change as being actively worked on. As the framework is already committed to my fork, and as it is a little hacky, I would appreciate feedback on it before I get too far into refactoring CCs and Alias.
Alternate implementation ideas are, as always, welcome.
Type
Description of the changes
Allows cogs to create their own command mapping, like
bot.all_commands, that can resolve command names into commands. These mappings are unique to each cog and cannot overwrite each other. If the bot fails to find a command by that name, it will look through all cog mappings instead before failing. This allows cogs to create specialized commands that can't be created through@commands.command.The mapping is automatically removed from the bot when the cog is unloaded; no
__unloadnecessary. A cog can get its mapping viabot.get_cog_map(self).This change allows specialized and/or dynamic commands, like those from CustomCommands and Alias, to count as full commands as far as the bot is concerned, while still allowing for dynamic changes simply via modifying the cog's own mapping without fear of damaging command data from other cogs or the bot itself.
Once complete, this PR will address #1920 and #1921, since special commands can be found via
bot.all_commands/bot.get_command, simplifying commands like[p]cleanup botthat look for command messages. Special commands will also dispatch command events as normal. (CCs already has this feature due to #2051, but this will extend the feature to other special cog commands.)Known issues
bot.all_commandsandbot.get_commandto search through all mappings when read. Acore_mapproperty is available to read from only the bot's standard commands, ignoring cog mappings. I plan to implement anothers_mapmethod to return a map that only looks through mappings not belonging to the cog. Writes and deletions tobot.all_commandsstill only affect standard commands, so this won't change that side of the bot's functionality.Pushed some CC changes. Feel free to take a look while I work on alias next.
Closing this in favor of a planned rewrite later on down the line.
Pull request closed