|
10 | 10 | from discord.ext import commands |
11 | 11 | from discord.ext.commands import Cog, Context |
12 | 12 | 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 |
14 | 14 |
|
15 | 15 | from bot.constants import Channels, DEBUG_MODE, RedirectOutput |
16 | 16 | from bot.log import get_logger |
@@ -156,22 +156,34 @@ async def inner(self: Cog, ctx: Context, *args, **kwargs) -> None: |
156 | 156 | log.trace(f"Redirecting output of {ctx.author}'s command '{ctx.command.name}' to {redirect_channel.name}") |
157 | 157 | ctx.channel = redirect_channel |
158 | 158 |
|
159 | | - try: |
160 | | - paste_link = None |
161 | | - async with ClientSession() as session: |
| 159 | + paste_link = None |
| 160 | + async with ClientSession() as session: |
| 161 | + try: |
162 | 162 | paste_response = await send_to_paste_service( |
163 | 163 | files=[PasteFile(content=ctx.message.content, lexer="markdown")], |
164 | 164 | http_session=session, |
165 | | - ) |
| 165 | + ) |
166 | 166 | 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 | + ) |
167 | 172 |
|
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 = "" |
170 | 174 |
|
171 | 175 | 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}):" |
173 | 182 | 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 | + |
175 | 187 | scheduling.create_task(func(self, ctx, *args, **kwargs)) |
176 | 188 |
|
177 | 189 | message = await old_channel.send( |
|
0 commit comments