[Commands] Refactor command and group decorators #1818

Merged
Tobotimus merged 15 commits from V3/refactor_cmd_decorators into V3/develop 2018-08-26 15:25:25 +02:00
Tobotimus commented 2018-06-07 16:31:24 +02:00 (Migrated from github.com)

Curiously, these decorators were previously placed in the Command class. Whilst it hadn't caused any issues yet, there's no reason for them to be there. This puts them in a new overridden GroupMixin class, so that the bot also inherits these decorators.

I also added some tests as a sanity check, and also to make sure this shit doesn't break in the future.

Curiously, these decorators were previously placed in the `Command` class. Whilst it hadn't caused any issues yet, there's no reason for them to be there. This puts them in a new overridden `GroupMixin` class, so that the bot also inherits these decorators. I also added some tests as a sanity check, and also to make sure this shit doesn't break in the future.
Twentysix26 (Migrated from github.com) reviewed 2018-06-07 16:31:24 +02:00
tekulvw (Migrated from github.com) reviewed 2018-06-09 04:03:40 +02:00
tekulvw (Migrated from github.com) commented 2018-06-09 04:03:40 +02:00

Why call our own reference to BotBase? I don't see a whole lot of sense in doing this

Why call our own reference to `BotBase`? I don't see a whole lot of sense in doing this
Tobotimus (Migrated from github.com) reviewed 2018-06-09 05:21:16 +02:00
Tobotimus (Migrated from github.com) commented 2018-06-09 05:21:16 +02:00

We can change it to discord.ext.commands.bot.BotBase if you'd like, it wouldn't make a difference

We can change it to `discord.ext.commands.bot.BotBase` if you'd like, it wouldn't make a difference
Tobotimus (Migrated from github.com) reviewed 2018-06-09 05:22:25 +02:00
Tobotimus (Migrated from github.com) commented 2018-06-09 05:22:24 +02:00

I could instead subclass discord.ext.commands.bot.BotBase and add the GroupMixin there. It wouldn't be any different to the current setup but would simplify RedBase's direct inheritance

I could instead subclass `discord.ext.commands.bot.BotBase` and add the `GroupMixin` there. It wouldn't be any different to the current setup but would simplify `RedBase`'s direct inheritance
Tobotimus (Migrated from github.com) reviewed 2018-06-09 05:35:50 +02:00
Tobotimus (Migrated from github.com) commented 2018-06-09 05:35:50 +02:00

See here for an example of what I mean, I don't really think its necessary but all of this inheritance stuff is pretty confusing to some, perhaps this makes it a bit simpler? I'm not sure.

See [here](https://github.com/Cog-Creators/Red-DiscordBot/compare/V3/develop...Tobotimus:V3/refactor_cmd_decorators_2?expand=1#diff-b4e8893536462f5cd5d7e291288c4d5eR25) for an example of what I mean, I don't really think its necessary but all of this inheritance stuff is pretty confusing to some, perhaps this makes it a bit simpler? I'm not sure.
Tobotimus (Migrated from github.com) reviewed 2018-06-09 05:37:11 +02:00
Tobotimus (Migrated from github.com) commented 2018-06-09 05:37:11 +02:00

Sorry, this is probably a better way to show the example

Sorry, [this](https://github.com/Tobotimus/Red-DiscordBot/compare/V3/refactor_cmd_decorators...Tobotimus:V3/refactor_cmd_decorators_2?expand=1#diff-b4e8893536462f5cd5d7e291288c4d5eR25) is probably a better way to show the example
Kowlin commented 2018-07-12 01:54:37 +02:00 (Migrated from github.com)

Due to my inexperience I'm not gonna touch this in Beta 17. Todo for Beta 18

Due to my inexperience I'm not gonna touch this in Beta 17. Todo for Beta 18
mikeshardmind (Migrated from github.com) requested changes 2018-08-09 18:58:48 +02:00
mikeshardmind (Migrated from github.com) left a comment

Everything in the bot appears to be fine with these changes, but I do think a tweak to the mro here should be made.

Here's the mro for commands.group:

(<class 'redbot.core.commands.commands.Group'>, 
<class 'redbot.core.commands.commands.Command'>,
 <class 'redbot.core.commands.commands.GroupMixin'>, 

<class 'discord.ext.commands.core.Group'>,
<class 'discord.ext.commands.core.GroupMixin'>,
<class 'discord.ext.commands.core.Command'>,

<class 'object'>)

I'm very hesitant to have our explicit overrides have a different ordering here than discord.py's bases without extremely good reason for doing so, and that reason being documented for future maintaining. While it doesn't seem to matter currently, it seems a recipe for potential subtle, hard to debug breakage later.

Everything in the bot appears to be fine with these changes, but I do think a tweak to the mro here should be made. Here's the mro for commands.group: ```py (<class 'redbot.core.commands.commands.Group'>, <class 'redbot.core.commands.commands.Command'>, <class 'redbot.core.commands.commands.GroupMixin'>, <class 'discord.ext.commands.core.Group'>, <class 'discord.ext.commands.core.GroupMixin'>, <class 'discord.ext.commands.core.Command'>, <class 'object'>) ``` I'm very hesitant to have our explicit overrides have a different ordering here than discord.py's bases without extremely good reason for doing so, and that reason being documented for future maintaining. While it doesn't seem to matter currently, it seems a recipe for potential subtle, hard to debug breakage later.
calebj commented 2018-08-10 04:57:20 +02:00 (Migrated from github.com)
I've rebased and fixed the MRO in https://github.com/calebj/Red-DiscordBot/tree/v3/refactor_cmd_decorators
Tobotimus commented 2018-08-11 05:47:54 +02:00 (Migrated from github.com)

Thanks @calebj and @mikeshardmind, I've tweaked the MRO accordingly

Thanks @calebj and @mikeshardmind, I've tweaked the MRO accordingly
calebj (Migrated from github.com) approved these changes 2018-08-11 22:56:32 +02:00
calebj (Migrated from github.com) left a comment

I haven't noticed any issues so far while running this. Approving now that the MRO fix has been applied.

I haven't noticed any issues so far while running this. Approving now that the MRO fix has been applied.
mikeshardmind (Migrated from github.com) approved these changes 2018-08-16 21:28:45 +02:00
Kowlin (Migrated from github.com) approved these changes 2018-08-26 15:09:28 +02:00
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!1818
No description provided.