aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2019-11-15 10:33:09 +0100
committerGravatar GitHub <[email protected]>2019-11-15 10:33:09 +0100
commitded5bbe5bb6547b50647a8ed040e9803bd58a76e (patch)
tree45a518e20595a9dda3f88a11ebc777ccffc2bd68
parentRe-post attachments (diff)
Use a context manager for the buffer
Co-authored-by: Shirayuki Nekomata <[email protected]>
-rw-r--r--bot/cogs/moderation/modlog.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bot/cogs/moderation/modlog.py b/bot/cogs/moderation/modlog.py
index 6d4b66644..3c6731de6 100644
--- a/bot/cogs/moderation/modlog.py
+++ b/bot/cogs/moderation/modlog.py
@@ -127,10 +127,10 @@ class ModLog(Cog, name="ModLog"):
channel = self.bot.get_channel(channel_id)
out = []
for attachment in message.attachments:
- buffer = BytesIO()
- await attachment.save(buffer, use_cached=True)
- reupload = await channel.send(file=discord.File(buffer, filename=attachment.filename))
- out.append(reupload.attachments[0].url)
+ with BytesIO() as buffer:
+ await attachment.save(buffer, use_cached=True)
+ reupload: discord.Message = await channel.send(file=discord.File(buffer, filename=attachment.filename))
+ out.append(reupload.attachments[0].url)
return out
@Cog.listener()