From 73a98df8882b5f56fbdf62b77fdbbcfcf5ad9f03 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Sun, 31 Aug 2025 18:28:31 -0400 Subject: [PATCH 01/23] Preserve Invocation Context --- bot/exts/utils/snekbox/_cog.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bot/exts/utils/snekbox/_cog.py b/bot/exts/utils/snekbox/_cog.py index 9607cd6dd3..19d8372e46 100644 --- a/bot/exts/utils/snekbox/_cog.py +++ b/bot/exts/utils/snekbox/_cog.py @@ -450,7 +450,18 @@ async def send_job(self, ctx: Context, job: EvalJob) -> Message: ) else: # The command was redirected so a reply wont work, send a normal message with a mention. - msg = f"{ctx.author.mention} {msg}" + try: + paste_response = await send_to_paste_service( + files=[PasteFile(content=ctx.message.content, lexer="markdown")], + http_session=self.bot.http_session, + paste_url=BaseURLs.paste_url, + ) + paste_link = paste_response.link + msg = f"Here's the output of your command\n{paste_link}:\n{msg}" + except paste_service.PasteUploadError: + # Fallback if paste service fails + msg = f"{ctx.author.mention} {msg}" + log.warning("Pastebin Upload Error") response = await ctx.send(msg, allowed_mentions=allowed_mentions, view=view, files=files) view.message = response From bd0944d8b18be382b52f7d51fcc9b88a10321631 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 1 Sep 2025 10:41:28 -0400 Subject: [PATCH 02/23] reverse changes --- bot/exts/utils/snekbox/_cog.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/bot/exts/utils/snekbox/_cog.py b/bot/exts/utils/snekbox/_cog.py index 19d8372e46..9607cd6dd3 100644 --- a/bot/exts/utils/snekbox/_cog.py +++ b/bot/exts/utils/snekbox/_cog.py @@ -450,18 +450,7 @@ async def send_job(self, ctx: Context, job: EvalJob) -> Message: ) else: # The command was redirected so a reply wont work, send a normal message with a mention. - try: - paste_response = await send_to_paste_service( - files=[PasteFile(content=ctx.message.content, lexer="markdown")], - http_session=self.bot.http_session, - paste_url=BaseURLs.paste_url, - ) - paste_link = paste_response.link - msg = f"Here's the output of your command\n{paste_link}:\n{msg}" - except paste_service.PasteUploadError: - # Fallback if paste service fails - msg = f"{ctx.author.mention} {msg}" - log.warning("Pastebin Upload Error") + msg = f"{ctx.author.mention} {msg}" response = await ctx.send(msg, allowed_mentions=allowed_mentions, view=view, files=files) view.message = response From 7851fe19f7258dcef2d22b431763196885a12ae6 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:14:26 -0400 Subject: [PATCH 03/23] Preserve Invocation context for all commands --- bot/decorators.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index a68f85d5bd..b3fb978fb4 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -5,12 +5,14 @@ from contextlib import suppress import arrow +from aiohttp import ClientSession from discord import Member, NotFound from discord.ext import commands from discord.ext.commands import Cog, Context from pydis_core.utils import scheduling +from pydis_core.utils.paste_service import PasteFile, send_to_paste_service -from bot.constants import Channels, DEBUG_MODE, RedirectOutput +from bot.constants import BaseURLs, Channels, DEBUG_MODE, RedirectOutput from bot.log import get_logger from bot.utils import function from bot.utils.checks import ContextCheckFailure, in_whitelist_check @@ -154,8 +156,19 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}") ctx.channel = redirect_channel + paste_link = None + async with ClientSession() as session: + paste_response = await send_to_paste_service( + files=[PasteFile(content=ctx.message.content, lexer="markdown")], + http_session=session, + paste_url=BaseURLs.paste_url, + ) + paste_link = paste_response.link + if ping_user: - await ctx.send(f"Here's the output of your command, {ctx.author.mention}") + await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}") + else: + await ctx.send(f"Here's the output of [your command]({paste_link})") scheduling.create_task(func(self, ctx, *args, **kwargs)) message = await old_channel.send( From f66b1434b4e4c246035ff99a2f51657337e8a8c0 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:26:27 -0400 Subject: [PATCH 04/23] Remove BaseURL --- bot/decorators.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index b3fb978fb4..2109ac5434 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -12,7 +12,7 @@ from pydis_core.utils import scheduling from pydis_core.utils.paste_service import PasteFile, send_to_paste_service -from bot.constants import BaseURLs, Channels, DEBUG_MODE, RedirectOutput +from bot.constants import Channels, DEBUG_MODE, RedirectOutput from bot.log import get_logger from bot.utils import function from bot.utils.checks import ContextCheckFailure, in_whitelist_check @@ -161,7 +161,6 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: paste_response = await send_to_paste_service( files=[PasteFile(content=ctx.message.content, lexer="markdown")], http_session=session, - paste_url=BaseURLs.paste_url, ) paste_link = paste_response.link From 831c489e5e37e6736025aff6a2a825ca9d752e6e Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:27:16 -0400 Subject: [PATCH 05/23] Change grammar --- bot/decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 2109ac5434..eedf5b9741 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -165,9 +165,9 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: paste_link = paste_response.link if ping_user: - await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}") + await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}:") else: - await ctx.send(f"Here's the output of [your command]({paste_link})") + await ctx.send(f"Here's the output of [your command]({paste_link}):") scheduling.create_task(func(self, ctx, *args, **kwargs)) message = await old_channel.send( From b7d70f9f3fd944afa3b88e25578add5d8618277c Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:00:19 -0400 Subject: [PATCH 06/23] Add Upload error exception --- bot/decorators.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index eedf5b9741..0921e2a098 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -10,7 +10,7 @@ from discord.ext import commands from discord.ext.commands import Cog, Context from pydis_core.utils import scheduling -from pydis_core.utils.paste_service import PasteFile, send_to_paste_service +from pydis_core.utils.paste_service import PasteFile, send_to_paste_service, PasteUploadError from bot.constants import Channels, DEBUG_MODE, RedirectOutput from bot.log import get_logger @@ -156,19 +156,22 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}") ctx.channel = redirect_channel - paste_link = None - async with ClientSession() as session: - paste_response = await send_to_paste_service( - files=[PasteFile(content=ctx.message.content, lexer="markdown")], - http_session=session, - ) - paste_link = paste_response.link - - if ping_user: - await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}:") - else: - await ctx.send(f"Here's the output of [your command]({paste_link}):") - scheduling.create_task(func(self, ctx, *args, **kwargs)) + try: + paste_link = None + async with ClientSession() as session: + paste_response = await send_to_paste_service( + files=[PasteFile(content=ctx.message.content, lexer="markdown")], + http_session=session, + ) + paste_link = paste_response.link + + if ping_user: + await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}:") + else: + await ctx.send(f"Here's the output of [your command]({paste_link}):") + scheduling.create_task(func(self, ctx, *args, **kwargs)) + except PasteUploadError: + log.exception("Failed to upload message %d in channel %d to paste service when redirecting output", ctx.message.channel.id, ctx.message.id) message = await old_channel.send( f"Hey, {ctx.author.mention}, you can find the output of your command here: " From 6dce0ccb5e393ae38f9d091cbdd031bce09f4062 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:14:29 -0400 Subject: [PATCH 07/23] Change the format --- bot/decorators.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 0921e2a098..c5c04486fc 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -165,14 +165,15 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: ) paste_link = paste_response.link - if ping_user: - await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}:") - else: - await ctx.send(f"Here's the output of [your command]({paste_link}):") - scheduling.create_task(func(self, ctx, *args, **kwargs)) except PasteUploadError: log.exception("Failed to upload message %d in channel %d to paste service when redirecting output", ctx.message.channel.id, ctx.message.id) + if ping_user: + await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}:") + else: + await ctx.send(f"Here's the output of [your command]({paste_link}):") + scheduling.create_task(func(self, ctx, *args, **kwargs)) + message = await old_channel.send( f"Hey, {ctx.author.mention}, you can find the output of your command here: " f"{redirect_channel.mention}" From 5c2341910da313edb2e467326397285086753f14 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:42:25 -0400 Subject: [PATCH 08/23] make message gradually and fix lint errors --- bot/decorators.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index c5c04486fc..d28aa3f13b 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -10,7 +10,7 @@ from discord.ext import commands from discord.ext.commands import Cog, Context from pydis_core.utils import scheduling -from pydis_core.utils.paste_service import PasteFile, send_to_paste_service, PasteUploadError +from pydis_core.utils.paste_service import PasteFile, PasteUploadError, send_to_paste_service from bot.constants import Channels, DEBUG_MODE, RedirectOutput from bot.log import get_logger @@ -156,22 +156,34 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}") ctx.channel = redirect_channel - try: - paste_link = None - async with ClientSession() as session: + paste_link = None + async with ClientSession() as session: + try: paste_response = await send_to_paste_service( files=[PasteFile(content=ctx.message.content, lexer="markdown")], http_session=session, - ) + ) paste_link = paste_response.link + except PasteUploadError: + log.exception( + "Failed to upload message %d in channel %d to paste service when redirecting output", + ctx.message.channel.id, ctx.message.id + ) - except PasteUploadError: - log.exception("Failed to upload message %d in channel %d to paste service when redirecting output", ctx.message.channel.id, ctx.message.id) + msg = "" if ping_user: - await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}:") + msg += f"{ctx.author.mention}, " + + msg += "Here's the output of " + + if paste_link: + msg += f"[your command]({paste_link}):" else: - await ctx.send(f"Here's the output of [your command]({paste_link}):") + msg += "your command:" + + await ctx.send(msg) + scheduling.create_task(func(self, ctx, *args, **kwargs)) message = await old_channel.send( From 3358598bfa37cf0fb962e30fb697cba4cd76d60f Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Tue, 2 Sep 2025 15:44:04 -0400 Subject: [PATCH 09/23] remove extra indent --- bot/decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index d28aa3f13b..23fbbed863 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -160,8 +160,8 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: async with ClientSession() as session: try: paste_response = await send_to_paste_service( - files=[PasteFile(content=ctx.message.content, lexer="markdown")], - http_session=session, + files=[PasteFile(content=ctx.message.content, lexer="markdown")], + http_session=session, ) paste_link = paste_response.link except PasteUploadError: From 080c8dcf200de25a4ffea9fc19a48e8342386971 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Tue, 2 Sep 2025 15:46:40 -0400 Subject: [PATCH 10/23] remove indent on parenthesis --- bot/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/decorators.py b/bot/decorators.py index 23fbbed863..9342c6b769 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -168,7 +168,7 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: log.exception( "Failed to upload message %d in channel %d to paste service when redirecting output", ctx.message.channel.id, ctx.message.id - ) + ) msg = "" From 7075d565b79928d9a4273bc5c94c04f8553253c7 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Tue, 2 Sep 2025 18:47:58 -0400 Subject: [PATCH 11/23] Add ternary conditions --- bot/decorators.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 9342c6b769..dacf80377f 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -172,15 +172,9 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: msg = "" - if ping_user: - msg += f"{ctx.author.mention}, " - - msg += "Here's the output of " - - if paste_link: - msg += f"[your command]({paste_link}):" - else: - msg += "your command:" + msg = "Here's the output of " + msg += f"[your command]({paste_link})" if paste_link else "your command" + msg += f", {ctx.author.mention}:" if ping_user else ":" await ctx.send(msg) From 14d79cb59c08192f7cd572f669560fd2a9d4ac9c Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Tue, 2 Sep 2025 20:59:51 -0400 Subject: [PATCH 12/23] Add DM to user for removal of code --- bot/decorators.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index dacf80377f..e256298bca 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -163,7 +163,6 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: files=[PasteFile(content=ctx.message.content, lexer="markdown")], http_session=session, ) - paste_link = paste_response.link except PasteUploadError: log.exception( "Failed to upload message %d in channel %d to paste service when redirecting output", @@ -173,11 +172,18 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: msg = "" msg = "Here's the output of " - msg += f"[your command]({paste_link})" if paste_link else "your command" + print(paste_response.link) + msg += f"[your command]({paste_response.link})" if paste_response else "your command" msg += f", {ctx.author.mention}:" if ping_user else ":" await ctx.send(msg) + #Send a DM to the user about the redirect and pastebin removal + await ctx.author.send( + content= + f"Your command output was redirected to <#{Channels.bot_commands}>. [Click here](<{paste_response.removal}>) to delete the automatically uploaded copy of your original command." + ) + scheduling.create_task(func(self, ctx, *args, **kwargs)) message = await old_channel.send( From ba6042804c559c69fb5cc8c534400eb5a7dff3c7 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Tue, 2 Sep 2025 21:06:11 -0400 Subject: [PATCH 13/23] Fix Lint errors --- bot/decorators.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index e256298bca..94b8000a92 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -156,7 +156,6 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}") ctx.channel = redirect_channel - paste_link = None async with ClientSession() as session: try: paste_response = await send_to_paste_service( @@ -172,7 +171,6 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: msg = "" msg = "Here's the output of " - print(paste_response.link) msg += f"[your command]({paste_response.link})" if paste_response else "your command" msg += f", {ctx.author.mention}:" if ping_user else ":" @@ -181,7 +179,9 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: #Send a DM to the user about the redirect and pastebin removal await ctx.author.send( content= - f"Your command output was redirected to <#{Channels.bot_commands}>. [Click here](<{paste_response.removal}>) to delete the automatically uploaded copy of your original command." + f"Your command output was redirected to <#{Channels.bot_commands}>." + f" [Click here](<{paste_response.removal}>) to delete the automatically" + "uploaded copy of your original command." ) scheduling.create_task(func(self, ctx, *args, **kwargs)) From 63de099186625712296d3949ec520a1dec3a4d95 Mon Sep 17 00:00:00 2001 From: Dragon <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Wed, 3 Sep 2025 06:49:16 -0400 Subject: [PATCH 14/23] change formatting Co-authored-by: Joe Banks --- bot/decorators.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 94b8000a92..238a65de70 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -176,12 +176,11 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: await ctx.send(msg) - #Send a DM to the user about the redirect and pastebin removal + # Send a DM to the user about the redirect and paste removal await ctx.author.send( - content= - f"Your command output was redirected to <#{Channels.bot_commands}>." - f" [Click here](<{paste_response.removal}>) to delete the automatically" - "uploaded copy of your original command." + f"Your command output was redirected to <#{Channels.bot_commands}>." + f" [Click here](<{paste_response.removal}>) to delete the pasted" + " copy of your original command." ) scheduling.create_task(func(self, ctx, *args, **kwargs)) From 35e69070f991f2adadcd345990abf712f2ff5885 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Wed, 3 Sep 2025 20:58:22 -0400 Subject: [PATCH 15/23] remove variable init --- bot/decorators.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 238a65de70..3afd78606b 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -168,8 +168,6 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: ctx.message.channel.id, ctx.message.id ) - msg = "" - msg = "Here's the output of " msg += f"[your command]({paste_response.link})" if paste_response else "your command" msg += f", {ctx.author.mention}:" if ping_user else ":" From a19c84c4dda774d87341ebfb2feb65c3819a83d8 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Thu, 4 Sep 2025 20:03:27 -0400 Subject: [PATCH 16/23] add forbidden error --- bot/decorators.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 3afd78606b..ab6a32f4f6 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -174,12 +174,15 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: await ctx.send(msg) - # Send a DM to the user about the redirect and paste removal - await ctx.author.send( - f"Your command output was redirected to <#{Channels.bot_commands}>." - f" [Click here](<{paste_response.removal}>) to delete the pasted" - " copy of your original command." - ) + try: + # Send a DM to the user about the redirect and paste removal + await ctx.author.send( + f"Your command output was redirected to <#{Channels.bot_commands}>." + f" [Click here](<{paste_response.removal}>) to delete the pasted" + " copy of your original command." + ) + except discord.Forbidden: + log.warning("Redirect output: Failed to send DM to user. Forbidden.") scheduling.create_task(func(self, ctx, *args, **kwargs)) From c5c7d5c2c22549c0056c89836a5f7c084abb71ac Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Thu, 4 Sep 2025 20:46:23 -0400 Subject: [PATCH 17/23] import discord --- bot/decorators.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/decorators.py b/bot/decorators.py index ab6a32f4f6..3f24405b3f 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -6,6 +6,7 @@ import arrow from aiohttp import ClientSession +import discord from discord import Member, NotFound from discord.ext import commands from discord.ext.commands import Cog, Context From a80044af4bda15f865cbbb3673632cf5cd6c4093 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Thu, 4 Sep 2025 20:48:01 -0400 Subject: [PATCH 18/23] fix lint errors --- bot/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/decorators.py b/bot/decorators.py index 3f24405b3f..2d26bdaa88 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -5,8 +5,8 @@ from contextlib import suppress import arrow -from aiohttp import ClientSession import discord +from aiohttp import ClientSession from discord import Member, NotFound from discord.ext import commands from discord.ext.commands import Cog, Context From 27733bbdb2f5f58f9181a2466761524e8d07861f Mon Sep 17 00:00:00 2001 From: Dragon <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Thu, 4 Sep 2025 21:01:24 -0400 Subject: [PATCH 19/23] reverse args Co-authored-by: Joe Banks --- bot/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/decorators.py b/bot/decorators.py index 2d26bdaa88..aa0f31428a 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -166,7 +166,7 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: except PasteUploadError: log.exception( "Failed to upload message %d in channel %d to paste service when redirecting output", - ctx.message.channel.id, ctx.message.id + ctx.message.id, ctx.message.channel.id ) msg = "Here's the output of " From 0ea257b4fe4d723ab9cf47f9540791fa20e59bb7 Mon Sep 17 00:00:00 2001 From: Dragon <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Thu, 4 Sep 2025 21:06:25 -0400 Subject: [PATCH 20/23] update logs Co-authored-by: Joe Banks --- bot/decorators.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/decorators.py b/bot/decorators.py index aa0f31428a..5a1fc5a8ae 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -183,7 +183,10 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: " copy of your original command." ) except discord.Forbidden: - log.warning("Redirect output: Failed to send DM to user. Forbidden.") + log.info( + "Failed to DM %s with redirected command paste removal link, user has bot DMs disabled", + ctx.author.name + ) scheduling.create_task(func(self, ctx, *args, **kwargs)) From c85a390ad78faa09dc41760c7aeaeb7bf03e6e22 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Fri, 19 Sep 2025 19:57:21 -0400 Subject: [PATCH 21/23] Add if statements --- bot/decorators.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 5a1fc5a8ae..1c1e627eaf 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -157,17 +157,19 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}") ctx.channel = redirect_channel - async with ClientSession() as session: - try: - paste_response = await send_to_paste_service( - files=[PasteFile(content=ctx.message.content, lexer="markdown")], - http_session=session, - ) - except PasteUploadError: - log.exception( - "Failed to upload message %d in channel %d to paste service when redirecting output", - ctx.message.id, ctx.message.channel.id - ) + paste_response = None + if RedirectOutput.delete_invocation: + async with ClientSession() as session: + try: + paste_response = await send_to_paste_service( + files=[PasteFile(content=ctx.message.content, lexer="markdown")], + http_session=session, + ) + except PasteUploadError: + log.exception( + "Failed to upload message %d in channel %d to paste service when redirecting output", + ctx.message.id, ctx.message.channel.id + ) msg = "Here's the output of " msg += f"[your command]({paste_response.link})" if paste_response else "your command" From 0e0fdea92cc14e6452bfd77a3e8503abb2cb618c Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 22 Sep 2025 20:08:54 -0400 Subject: [PATCH 22/23] add if for paste --- bot/decorators.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/bot/decorators.py b/bot/decorators.py index 1c1e627eaf..bc7bf9f010 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -176,19 +176,20 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: msg += f", {ctx.author.mention}:" if ping_user else ":" await ctx.send(msg) - - try: - # Send a DM to the user about the redirect and paste removal - await ctx.author.send( - f"Your command output was redirected to <#{Channels.bot_commands}>." - f" [Click here](<{paste_response.removal}>) to delete the pasted" - " copy of your original command." - ) - except discord.Forbidden: - log.info( - "Failed to DM %s with redirected command paste removal link, user has bot DMs disabled", - ctx.author.name - ) + + if paste_response: + try: + # Send a DM to the user about the redirect and paste removal + await ctx.author.send( + f"Your command output was redirected to <#{Channels.bot_commands}>." + f" [Click here](<{paste_response.removal}>) to delete the pasted" + " copy of your original command." + ) + except discord.Forbidden: + log.info( + "Failed to DM %s with redirected command paste removal link, user has bot DMs disabled", + ctx.author.name + ) scheduling.create_task(func(self, ctx, *args, **kwargs)) From bae3e25d8ee4e3be8cf27842af0323f4f9a748a7 Mon Sep 17 00:00:00 2001 From: DragonSenseiGuy <200907890+DragonSenseiGuy@users.noreply.github.com> Date: Mon, 22 Sep 2025 20:11:39 -0400 Subject: [PATCH 23/23] fix lint --- bot/decorators.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bot/decorators.py b/bot/decorators.py index bc7bf9f010..8a29a67d5d 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -176,7 +176,6 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: msg += f", {ctx.author.mention}:" if ping_user else ":" await ctx.send(msg) - if paste_response: try: # Send a DM to the user about the redirect and paste removal