diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/decorators.py | 22 | ||||
| -rw-r--r-- | bot/exts/utils/attachment_pastebin_uploader.py | 7 | 
2 files changed, 12 insertions, 17 deletions
| diff --git a/bot/decorators.py b/bot/decorators.py index 8a29a67d5..d39c1cc33 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -6,7 +6,6 @@ from contextlib import suppress  import arrow  import discord -from aiohttp import ClientSession  from discord import Member, NotFound  from discord.ext import commands  from discord.ext.commands import Cog, Context @@ -159,17 +158,16 @@ def redirect_output(              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 -                        ) +                try: +                    paste_response = await send_to_paste_service( +                        files=[PasteFile(content=ctx.message.content, lexer="markdown")], +                        http_session=ctx.bot.http_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" diff --git a/bot/exts/utils/attachment_pastebin_uploader.py b/bot/exts/utils/attachment_pastebin_uploader.py index 03439390b..9a805dd66 100644 --- a/bot/exts/utils/attachment_pastebin_uploader.py +++ b/bot/exts/utils/attachment_pastebin_uploader.py @@ -2,7 +2,6 @@ from __future__ import annotations  import re -import aiohttp  import discord  from discord.ext import commands  from pydis_core.utils import paste_service @@ -116,8 +115,7 @@ class AutoTextAttachmentUploader(commands.Cog):          # Upload the files to the paste bin, exiting early if there's an error.          log.trace(f"Attempting to upload {len(files)} file(s) to pastebin.")          try: -            async with aiohttp.ClientSession() as session: -                paste_response = await paste_service.send_to_paste_service(files=files, http_session=session) +            paste_response = await paste_service.send_to_paste_service(files=files, http_session=self.bot.http_session)          except (paste_service.PasteTooLongError, ValueError):              log.trace(f"{message.author}'s attachments were too long.")              await bot_reply.edit(content="Your paste is too long, and couldn't be uploaded.") @@ -145,8 +143,7 @@ class AutoTextAttachmentUploader(commands.Cog):              return          # Delete the paste and the bot's message. -        async with aiohttp.ClientSession() as session: -            await session.get(paste_response.removal) +        await self.bot.http_session.get(paste_response.removal)          await bot_reply.delete() | 
