diff options
-rw-r--r-- | bot/resources/tags/customchecks.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bot/resources/tags/customchecks.md b/bot/resources/tags/customchecks.md index 4f0d62c8d..b4eb90872 100644 --- a/bot/resources/tags/customchecks.md +++ b/bot/resources/tags/customchecks.md @@ -1,6 +1,6 @@ **Custom Command Checks in discord.py** -You may find yourself in need of a decorator to do something that doesn't exist in discord.py by default, but fear not, you can make your own! Using discord.py you can use `discord.ext.commands.check` to create you own decorators like this: +You may find yourself in need of a check decorator to do something that doesn't exist in discord.py by default, but fear not, you can make your own! Using discord.py you can use `discord.ext.commands.check` to create you own checks like this: ```py from discord.ext.commands import check, Context @@ -9,9 +9,9 @@ def in_channel(*channels): return ctx.channel.id in channels return check(predicate) ``` -There's a fair bit to break down here, so let's start with what we're trying to achieve with this decorator. As you can probably guess from the name it's locking a command to a list of channels. The inner function named `predicate` is used to perform the actual check on the command context. Here you can do anything that requires a `Context` object. This inner function should return `True` if the check is **successful** or `False` if the check **fails**. +There's a fair bit to break down here, so let's start with what we're trying to achieve with this check. As you can probably guess from the name it's locking a command to a list of channels. The inner function named `predicate` is used to perform the actual check on the command context. Here you can do anything that requires a `Context` object. This inner function should return `True` if the check is **successful** or `False` if the check **fails**. -Here's how we might use our new decorator: +Here's how we might use our new check: ```py @bot.command(name="ping") @in_channel(728343273562701984) |