Skip to content

Commit 73be848

Browse files
Preserve Invocation context for all commands
1 parent 772f298 commit 73be848

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

bot/decorators.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
from contextlib import suppress
66

77
import arrow
8+
from aiohttp import ClientSession
89
from discord import Member, NotFound
910
from discord.ext import commands
1011
from discord.ext.commands import Cog, Context
1112
from pydis_core.utils import scheduling
13+
from pydis_core.utils.paste_service import PasteFile, send_to_paste_service
1214

13-
from bot.constants import Channels, DEBUG_MODE, RedirectOutput
15+
from bot.constants import BaseURLs, Channels, DEBUG_MODE, RedirectOutput
1416
from bot.log import get_logger
1517
from bot.utils import function
1618
from bot.utils.checks import ContextCheckFailure, in_whitelist_check
@@ -154,8 +156,19 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None:
154156
log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}")
155157
ctx.channel = redirect_channel
156158

159+
paste_link = None
160+
async with ClientSession() as session:
161+
paste_response = await send_to_paste_service(
162+
files=[PasteFile(content=ctx.message.content, lexer="markdown")],
163+
http_session=session,
164+
paste_url=BaseURLs.paste_url,
165+
)
166+
paste_link = paste_response.link
167+
157168
if ping_user:
158-
await ctx.send(f"Here's the output of your command, {ctx.author.mention}")
169+
await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}")
170+
else:
171+
await ctx.send(f"Here's the output of [your command]({paste_link})")
159172
scheduling.create_task(func(self, ctx, *args, **kwargs))
160173

161174
message = await old_channel.send(

0 commit comments

Comments
 (0)