diff options
author | 2021-02-02 06:05:46 +0530 | |
---|---|---|
committer | 2021-02-02 06:05:46 +0530 | |
commit | 3e884eaa43b78b433a470aaff39b03a0f6c2b3c2 (patch) | |
tree | 64e5c26eb6e31164681471ce43fce47230b6adea /bot/exts/evergreen/cheatsheet.py | |
parent | Add override_in_channel deco (diff) |
Allow cht.sh command to be used in occupied help channels
Diffstat (limited to 'bot/exts/evergreen/cheatsheet.py')
-rw-r--r-- | bot/exts/evergreen/cheatsheet.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bot/exts/evergreen/cheatsheet.py b/bot/exts/evergreen/cheatsheet.py index c83af839..83098c76 100644 --- a/bot/exts/evergreen/cheatsheet.py +++ b/bot/exts/evergreen/cheatsheet.py @@ -3,13 +3,13 @@ import re import typing as t from urllib.parse import quote_plus -from discord import Embed +from discord import Embed, utils from discord.ext import commands from discord.ext.commands import BucketType, Context from bot import constants -from bot.constants import Channels, Colours, ERROR_REPLIES, WHITELISTED_CHANNELS -from bot.utils.decorators import override_in_channel +from bot.constants import Categories, Channels, Colours, ERROR_REPLIES, Roles, WHITELISTED_CHANNELS +from bot.utils.decorators import with_role ERROR_MESSAGE = f""" Unknown cheat sheet. Please try to reformulate your query. @@ -72,8 +72,8 @@ class CheatSheet(commands.Cog): name="cheat", aliases=("cht.sh", "cheatsheet", "cheat-sheet", "cht"), ) - @override_in_channel(WHITELISTED_CHANNELS) @commands.cooldown(1, 10, BucketType.user) + @with_role(Roles.everyone) async def cheat_sheet(self, ctx: Context, *search_terms: str) -> None: """ Search cheat.sh. @@ -82,6 +82,11 @@ class CheatSheet(commands.Cog): Usage: --> .cht read json """ + category = utils.get(ctx.message.guild.categories, id=Categories.help_in_use) + all_allowed_channels = WHITELISTED_CHANNELS + tuple(category.channels) + if ctx.channel not in all_allowed_channels: + return + async with self.bot.http_session.get( URL.format(search=quote_plus(" ".join(search_terms))) ) as response: |