diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/constants.py | 11 | ||||
| -rw-r--r-- | bot/exts/evergreen/cheatsheet.py | 13 | 
2 files changed, 14 insertions, 10 deletions
| diff --git a/bot/constants.py b/bot/constants.py index 1d41a53e..23865272 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -104,12 +104,6 @@ class Channels(NamedTuple):      devlog = int(environ.get("CHANNEL_DEVLOG", 622895325144940554))      dev_contrib = 635950537262759947      dev_branding = 753252897059373066 -    help_0 = 303906576991780866 -    help_1 = 303906556754395136 -    help_2 = 303906514266226689 -    help_3 = 439702951246692352 -    help_4 = 451312046647148554 -    help_5 = 454941769734422538      helpers = 385474242440986624      message_log = 467752170159079424      mod_alerts = 473092532147060736 @@ -128,6 +122,10 @@ class Channels(NamedTuple):      voice_chat_1 = 799647045886541885 +class Categories(NamedTuple): +    help_in_use = 696958401460043776 + +  class Client(NamedTuple):      name = "Sir Lancebot"      guild = int(environ.get("BOT_GUILD", 267624335836053506)) @@ -249,6 +247,7 @@ class Roles(NamedTuple):      rockstars = 458226413825294336      core_developers = 587606783669829632      events_lead = 778361735739998228 +    everyone = 267624335836053506  class Tokens(NamedTuple): 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: | 
