diff options
author | 2021-03-27 13:52:43 -0400 | |
---|---|---|
committer | 2021-03-27 13:52:43 -0400 | |
commit | 4be90b3c454138e3548c7394fcb2a1182b05b7d7 (patch) | |
tree | 17ec266a9a23e7999884a52d5cd062433dc91873 | |
parent | Create the new DMRelay cog. (diff) |
Restrict DMRelay cog to moderators only.
-rw-r--r-- | bot/exts/moderation/dm_relay.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/bot/exts/moderation/dm_relay.py b/bot/exts/moderation/dm_relay.py index 2bf2391a4..1d57862d9 100644 --- a/bot/exts/moderation/dm_relay.py +++ b/bot/exts/moderation/dm_relay.py @@ -2,10 +2,10 @@ import logging import textwrap import discord -from discord.ext.commands import Cog, Context, command +from discord.ext.commands import Cog, Context, command, has_any_role from bot.bot import Bot -from bot.constants import Emojis +from bot.constants import Emojis, MODERATION_ROLES from bot.utils.services import send_to_paste_service log = logging.getLogger(__name__) @@ -53,6 +53,10 @@ class DMRelay(Cog): paste_link = await send_to_paste_service(output, extension="txt") await ctx.send(paste_link) + async def cog_check(self, ctx: Context) -> bool: + """Only allow moderators to invoke the commands in this cog.""" + return await has_any_role(*MODERATION_ROLES).predicate(ctx) + def setup(bot: Bot) -> None: """Load the DMRelay cog.""" |