aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Atul Mishra <[email protected]>2019-10-22 21:53:39 +0530
committerGravatar Atul Mishra <[email protected]>2019-10-22 21:53:39 +0530
commit1dc08b8622b4d99bc7c480da5f91f774fdfd0787 (patch)
tree9d867a5a38e4ca8fb544548d51371372e2a7a87f
parentFix typo in channel name (diff)
Modify in_channel_check to accept list of channels
- Update test cases for in_channel_check
Diffstat (limited to '')
-rw-r--r--bot/utils/checks.py6
-rw-r--r--tests/utils/test_checks.py8
2 files changed, 7 insertions, 7 deletions
diff --git a/bot/utils/checks.py b/bot/utils/checks.py
index ad892e512..db56c347c 100644
--- a/bot/utils/checks.py
+++ b/bot/utils/checks.py
@@ -38,9 +38,9 @@ def without_role_check(ctx: Context, *role_ids: int) -> bool:
return check
-def in_channel_check(ctx: Context, channel_id: int) -> bool:
- """Checks if the command was executed inside of the specified channel."""
- check = ctx.channel.id == channel_id
+def in_channel_check(ctx: Context, *channel_ids: int) -> bool:
+ """Checks if the command was executed inside the list of specified channels."""
+ check = ctx.channel.id in channel_ids
log.trace(f"{ctx.author} tried to call the '{ctx.command.name}' command. "
f"The result of the in_channel check was {check}.")
return check
diff --git a/tests/utils/test_checks.py b/tests/utils/test_checks.py
index 7121acebd..ef1144ac9 100644
--- a/tests/utils/test_checks.py
+++ b/tests/utils/test_checks.py
@@ -57,10 +57,10 @@ def test_without_role_check_without_unwanted_role(context):
def test_in_channel_check_for_correct_channel(context):
- context.channel.id = 42
- assert checks.in_channel_check(context, context.channel.id)
+ context.channel.id = [42]
+ assert checks.in_channel_check(context, *context.channel.id)
def test_in_channel_check_for_incorrect_channel(context):
- context.channel.id = 42
- assert not checks.in_channel_check(context, context.channel.id + 10)
+ context.channel.id = [42 + 10]
+ assert not checks.in_channel_check(context, *context.channel.id)