diff options
| -rw-r--r-- | bot/exts/info/code_snippets.py | 22 | 
1 files changed, 17 insertions, 5 deletions
| diff --git a/bot/exts/info/code_snippets.py b/bot/exts/info/code_snippets.py index 3b2a8a0a5..06885410b 100644 --- a/bot/exts/info/code_snippets.py +++ b/bot/exts/info/code_snippets.py @@ -9,6 +9,7 @@ from discord import Message  from discord.ext.commands import Cog  from bot.bot import Bot +from bot.constants import Channels  from bot.utils.messages import wait_for_deletion  log = logging.getLogger(__name__) @@ -240,12 +241,23 @@ class CodeSnippets(Cog):              # Sorts the list of snippets by their match index and joins them into a single message              message_to_send = '\n'.join(map(lambda x: x[1], sorted(all_snippets))) -            if 0 < len(message_to_send) <= 2000 and len(all_snippets) <= 15: +            if 0 < len(message_to_send) <= 2000 and message_to_send.count('\n') <= 15:                  await message.edit(suppress=True) -                await wait_for_deletion( -                    await message.channel.send(message_to_send), -                    (message.author.id,) -                ) +                if len(message_to_send) > 1000 and message.channel.id != Channels.bot_commands: +                    # Redirects to #bot-commands if the snippet contents are too long +                    await self.bot.wait_until_guild_available() +                    await message.channel.send(('The snippet you tried to send was too long. Please ' +                                                f'see <#{Channels.bot_commands}> for the full snippet.')) +                    bot_commands_channel = self.bot.get_channel(Channels.bot_commands) +                    await wait_for_deletion( +                        await bot_commands_channel.send(message_to_send), +                        (message.author.id,) +                    ) +                else: +                    await wait_for_deletion( +                        await message.channel.send(message_to_send), +                        (message.author.id,) +                    )  def setup(bot: Bot) -> None: | 
