[V3] enforce commands as ours #1971

Merged
mikeshardmind merged 6 commits from enforce-commands into V3/develop 2018-08-13 03:10:14 +02:00
mikeshardmind commented 2018-08-02 01:30:44 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Prevents cogs not using our command module from being added (#1880)

Why in cog load

Rather than do this at the command level, it makes more sense to do at the cog level to prevent the cog from even being partially added.

### Type - [ ] Bugfix - [ ] Enhancement - [ ] New feature ### Description of the changes Prevents cogs not using our command module from being added (#1880) ### Why in cog load Rather than do this at the command level, it makes more sense to do at the cog level to prevent the cog from even being partially added.
palmtree5 (Migrated from github.com) reviewed 2018-08-02 01:30:44 +02:00
tekulvw (Migrated from github.com) reviewed 2018-08-02 01:30:44 +02:00
Twentysix26 (Migrated from github.com) reviewed 2018-08-02 01:30:44 +02:00
PgoTracker commented 2018-08-02 10:20:42 +02:00 (Migrated from github.com)

Forgive me but why is it important to use your system and not the built in ?

Forgive me but why is it important to use your system and not the built in ?
Tobotimus commented 2018-08-02 14:05:35 +02:00 (Migrated from github.com)

@useruser3 It's true that this change (especially being a breaking one) deserves some more explanation. I've opened #1972 to shed some light here and perhaps open up some discussion if necessary.

@useruser3 It's true that this change (especially being a breaking one) deserves some more explanation. I've opened #1972 to shed some light here and perhaps open up some discussion if necessary.
Tobotimus (Migrated from github.com) reviewed 2018-08-02 14:52:46 +02:00
Redjumpman commented 2018-08-03 18:12:38 +02:00 (Migrated from github.com)

I think this is a good change. If anything, it helps curb the muscle memory of always using discord.ext. My recommendation is to include a blurb in the docs the reasoning behind why we subclassed commands.Command. While on this topic, it might be beneficial to have a section of all Red specific utilities that should be used over standard d.py.

I think this is a good change. If anything, it helps curb the muscle memory of always using discord.ext. My recommendation is to include a blurb in the docs the reasoning behind why we subclassed `commands.Command`. While on this topic, it might be beneficial to have a section of all Red specific utilities that should be used over standard d.py.
mikeshardmind commented 2018-08-03 21:55:24 +02:00 (Migrated from github.com)

More on the last point by @redjumpman we have a cog cookiecutter repo which will be documented soon to help alleviate any adjustments like this for new cog creators as well

More on the last point by @redjumpman we have a cog cookiecutter repo which will be documented soon to help alleviate any adjustments like this for new cog creators as well
Redjumpman (Migrated from github.com) requested changes 2018-08-07 22:14:51 +02:00
Redjumpman (Migrated from github.com) left a comment

Running this currently results in a TypeError

TypeError: isinstance() arg 2 must be a type or tuple of types.

I tried calling type() on attr and the return of getattr and was able to get it to move past that error. I think because when iterating over dir, not everything is returned as a type.

However, this does get the runtime error to raise, but I think unexpectedly for the one time we need it.

RuntimeError: redbot.core.core_commands is not using Red's command module, and cannot be added.

Running this currently results in a `TypeError` `TypeError: isinstance() arg 2 must be a type or tuple of types.` I tried calling `type()` on attr and the return of `getattr` and was able to get it to move past *that* error. I think because when iterating over dir, not everything is returned as a type. However, this does get the runtime error to raise, but I think unexpectedly for the one time we need it. `RuntimeError: redbot.core.core_commands is not using Red's command module, and cannot be added.`
mikeshardmind commented 2018-08-08 15:28:34 +02:00 (Migrated from github.com)

This should be working all the time now, rather than only in the small toy test case I was using for it before.

This should be working all the time now, rather than only in the small toy test case I was using for it before.
Redjumpman (Migrated from github.com) reviewed 2018-08-09 00:59:13 +02:00
Redjumpman (Migrated from github.com) commented 2018-08-09 00:59:13 +02:00

cog.__class__.__name should be cog.__class__.__name__ otherwise it raises an attribute error.

`cog.__class__.__name` should be `cog.__class__.__name__` otherwise it raises an attribute error.
Redjumpman (Migrated from github.com) requested changes 2018-08-09 01:03:11 +02:00
Redjumpman (Migrated from github.com) left a comment

After the change I marked is fixed, the message reports as RuntimeError: RussianRoulette from russianroulette.russianroulette, is not using Red's command module, and cannot be add ed. I think this could be written a little more clearly as "The RussianRoulette cog in the russianroulette.russianroulette package must use from redbot.core import commands, instead of from discord.ext import commands." Something along those lines.

After the change I marked is fixed, the message reports as `RuntimeError: RussianRoulette from russianroulette.russianroulette, is not using Red's command module, and cannot be add ed.` I think this could be written a little more clearly as "The RussianRoulette cog in the russianroulette.russianroulette package must use from redbot.core import commands, instead of from discord.ext import commands." Something along those lines.
mikeshardmind commented 2018-08-09 03:31:36 +02:00 (Migrated from github.com)

@Redjumpman Sorry, I feel like an idiot after that last minute change to give more detailed errors. That's been fixed, and I've added a documentation link to the error, along with a slight tweak to the documentation making it clear that we have additional methods there for red specific things.

@Redjumpman Sorry, I feel like an idiot after that last minute change to give more detailed errors. That's been fixed, and I've added a documentation link to the error, along with a slight tweak to the documentation making it clear that we have additional methods there for red specific things.
Redjumpman commented 2018-08-09 07:41:03 +02:00 (Migrated from github.com)

Awesome. Everything works great. This is now ready for the next release.

Awesome. Everything works great. This is now ready for the next release.
Redjumpman (Migrated from github.com) approved these changes 2018-08-09 07:41:09 +02:00
Tobotimus commented 2018-08-09 08:33:23 +02:00 (Migrated from github.com)

Thanks for reviewing @Redjumpman, but considering this is a breaking change we haven't announced for yet, and beta 19 being due this Sunday August 12, I'm going to block this until after beta 19.

Thanks for reviewing @Redjumpman, but considering this is a breaking change we haven't announced for yet, and beta 19 being due this Sunday August 12, I'm going to block this until after beta 19.
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!1971
No description provided.