Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type
Tasks
MessagePredicate
@classmethod
s 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
ctx
is often tightly coupled in these scenarios, you may find yourself writing simple predicates like the aboveconfirm
function 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
, orno
Note: All methods require that the sender and the message author be the same.