Beispiel #1
0
 def cog_check(self, ctx: Context) -> bool:
     """Only allow moderators from moderator channels to invoke the commands in this cog."""
     checks = [
         with_role_check(ctx, *constants.MODERATION_ROLES),
         in_channel_check(ctx, *constants.MODERATION_CHANNELS)
     ]
     return all(checks)
Beispiel #2
0
 def test_in_channel_check_for_incorrect_channel(self):
     self.ctx.channel.id = 42 + 10
     self.assertFalse(checks.in_channel_check(self.ctx, *[42]))
Beispiel #3
0
 def test_in_channel_check_for_correct_channel(self):
     self.ctx.channel.id = 42
     self.assertTrue(checks.in_channel_check(self.ctx, *[42]))
Beispiel #4
0
def test_in_channel_check_for_incorrect_channel(context):
    context.channel.id = 42
    assert not checks.in_channel_check(context, context.channel.id + 10)