Allow pre_invoke to be used by 3rd party cogs safely. #3369

Merged
mikeshardmind merged 10 commits from pre-invoke into V3/develop 2020-01-16 02:44:21 +01:00
mikeshardmind commented 2020-01-15 00:28:47 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Okay, so there's a lot in this diff, but the idea is to actually be able to allow 3rd party cogs to use pre_invoke globally without conflicting eachother, or disrupting other goals with the bot.

### Type - [ ] Bugfix - [X] Enhancement - [ ] New feature ### Description of the changes Okay, so there's a lot in this diff, but the idea is to actually be able to allow 3rd party cogs to use pre_invoke globally without conflicting eachother, or disrupting other goals with the bot.
tekulvw (Migrated from github.com) reviewed 2020-01-15 00:28:47 +01:00
Twentysix26 (Migrated from github.com) reviewed 2020-01-15 00:28:47 +01:00
Jackenmen (Migrated from github.com) requested changes 2020-01-16 01:59:24 +01:00
Jackenmen (Migrated from github.com) commented 2020-01-16 01:32:21 +01:00

Would this work as a type hint or is there something I'm missing?

T_BIC = TypeVar("T_BIC", Callable[[commands.Context], Awaitable[Any]])
Would this work as a type hint or is there something I'm missing? ```suggestion T_BIC = TypeVar("T_BIC", Callable[[commands.Context], Awaitable[Any]]) ```
Jackenmen (Migrated from github.com) commented 2020-01-16 01:03:48 +01:00

We might want to put a # DEP-WARN here in case this gets changed.

We might want to put a `# DEP-WARN` here in case this gets changed.
Jackenmen (Migrated from github.com) commented 2020-01-16 01:08:09 +01:00
        Overridden decorator method for Red's `before_invoke` behavior.
```suggestion Overridden decorator method for Red's `before_invoke` behavior. ```
Jackenmen (Migrated from github.com) commented 2020-01-16 01:08:39 +01:00
        Functional method to remove a `before_invoke` hook.
```suggestion Functional method to remove a `before_invoke` hook. ```
Jackenmen (Migrated from github.com) commented 2020-01-16 01:09:13 +01:00
        """Prevent this from being overwritten in super().__init__"""
```suggestion """Prevent this from being overwritten in super().__init__""" ```
Jackenmen (Migrated from github.com) commented 2020-01-16 01:09:36 +01:00
        Below behavior shared with discord.py:
```suggestion Below behavior shared with discord.py: ```
Jackenmen (Migrated from github.com) commented 2020-01-16 01:09:53 +01:00
            The `before_invoke` hooks are
```suggestion The `before_invoke` hooks are ```
Jackenmen (Migrated from github.com) commented 2020-01-16 01:20:03 +01:00
        using `remove_before_invoke_hook`
```suggestion using `remove_before_invoke_hook` ```
Jackenmen (Migrated from github.com) commented 2020-01-16 01:31:21 +01:00

I think we should put some type in docs, not sure if it should be this one though.

        coro: Callable[[commands.Context], Awaitable[Any]]
I think we should put some type in docs, not sure if it should be this one though. ```suggestion coro: Callable[[commands.Context], Awaitable[Any]] ```
@ -153,0 +212,4 @@
----------
coro: Callable[[commands.Context], Awaitable[Any]]
The coroutine to register as the pre-invoke hook.
Jackenmen (Migrated from github.com) commented 2020-01-16 01:18:24 +01:00

Does this sentence mean that I don't have to use it as deco or...?

Does this sentence mean that I don't have to use it as deco or...?
mikeshardmind (Migrated from github.com) reviewed 2020-01-16 02:00:59 +01:00
@ -153,0 +212,4 @@
----------
coro: Callable[[commands.Context], Awaitable[Any]]
The coroutine to register as the pre-invoke hook.
mikeshardmind (Migrated from github.com) commented 2020-01-16 02:00:58 +01:00

Yes. bot.before_invoke(cog.some_func) is acceptable.

Yes. `bot.before_invoke(cog.some_func)` is acceptable.
mikeshardmind (Migrated from github.com) reviewed 2020-01-16 02:02:35 +01:00
mikeshardmind (Migrated from github.com) commented 2020-01-16 02:02:35 +01:00

I'm not sure our docs handle this, but if not, we can adjust it, I'm adding it.

I'm not sure our docs handle this, but if not, we can adjust it, I'm adding it.
Jackenmen (Migrated from github.com) reviewed 2020-01-16 02:26:04 +01:00
Jackenmen (Migrated from github.com) left a comment
No description provided.
LGTM, but leaving this merge to Sinbad as he has a cog that can benefit from this addition and he might notice something I didn't.
Jackenmen (Migrated from github.com) approved these changes 2020-01-16 02:42:47 +01: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!3369
No description provided.