Skip to content

Commit fc900e5

Browse files
make message gradually and fix lint errors
1 parent 436cb62 commit fc900e5

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

bot/decorators.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from discord.ext import commands
1111
from discord.ext.commands import Cog, Context
1212
from pydis_core.utils import scheduling
13-
from pydis_core.utils.paste_service import PasteFile, send_to_paste_service, PasteUploadError
13+
from pydis_core.utils.paste_service import PasteFile, PasteUploadError, send_to_paste_service
1414

1515
from bot.constants import Channels, DEBUG_MODE, RedirectOutput
1616
from bot.log import get_logger
@@ -156,22 +156,34 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None:
156156
log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}")
157157
ctx.channel = redirect_channel
158158

159-
try:
160-
paste_link = None
161-
async with ClientSession() as session:
159+
paste_link = None
160+
async with ClientSession() as session:
161+
try:
162162
paste_response = await send_to_paste_service(
163163
files=[PasteFile(content=ctx.message.content, lexer="markdown")],
164164
http_session=session,
165-
)
165+
)
166166
paste_link = paste_response.link
167+
except PasteUploadError:
168+
log.exception(
169+
"Failed to upload message %d in channel %d to paste service when redirecting output",
170+
ctx.message.channel.id, ctx.message.id
171+
)
167172

168-
except PasteUploadError:
169-
log.exception("Failed to upload message %d in channel %d to paste service when redirecting output", ctx.message.channel.id, ctx.message.id)
173+
msg = ""
170174

171175
if ping_user:
172-
await ctx.send(f"Here's the output of [your command]({paste_link}), {ctx.author.mention}:")
176+
msg += f"{ctx.author.mention}, "
177+
178+
msg += "Here's the output of "
179+
180+
if paste_link:
181+
msg += f"[your command]({paste_link}):"
173182
else:
174-
await ctx.send(f"Here's the output of [your command]({paste_link}):")
183+
msg += "your command:"
184+
185+
await ctx.send(msg)
186+
175187
scheduling.create_task(func(self, ctx, *args, **kwargs))
176188

177189
message = await old_channel.send(

0 commit comments

Comments
 (0)