[V3 Utils] Predicate Utility #1986
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 project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!1986
Loading…
Reference in a new issue
No description provided.
Delete branch "V3/feature/predicates"
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?
Type
Tasks
MessagePredicate@classmethods for instantiation... probably more to be added
Description of the changes
(PR Description copied from #1985, originally written by @Redjumpman)
I often find myself and other cog creators having to write a bunch of boiler plate checks either through functions or lambdas for multiple cogs that need waiting events. Specifically, for when you need to validate a response. Suppose the following scenario:
Because
ctxis often tightly coupled in these scenarios, you may find yourself writing simple predicates like the aboveconfirmfunction or an equivalent lambda over and over across multiple commands or cogs.Enter the new Predicates core utility module! This solves the problem with reusable predicates. Take the following example into consideration:
In the above code, we bypass having to write two separate checks by using Predicate. The Predicate class comes with the following methods:
yes,y,no, ornoNote: All methods require that the sender and the message author be the same.
I'd like a mixed listener that allows for waiting for a reaction or message meeting criteria, but this is going to require working with
socket_raw_recieve, I'll write something for this later. and it shouldnt hold up the initial work on this PR being merged if I dont have it ready by the time this is ready for review.About to rebase+force push this PR branch.
Just want to post this for the record, the header of this PR is out of date and should not be used as a guide for this feature; see the documentation after this PR is merged for details 😃