Fix wastebasket deletion
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s

This commit is contained in:
Nexus 2024-06-01 13:31:22 +01:00
parent c516191bfd
commit 899e9c84dd
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -366,19 +366,25 @@ class AutoResponder(commands.Cog):
extra = [attachment.url for attachment in reaction.message.attachments] extra = [attachment.url for attachment in reaction.message.attachments]
if self.allow_on_demand_transcoding: if self.allow_on_demand_transcoding:
await self.transcode_hevc_to_h264(reaction.message, additional=extra) await self.transcode_hevc_to_h264(reaction.message, additional=extra)
if reaction.emoji == "\U0001f310": elif str(reaction.emoji) == "\U0001f310":
if reaction.message.id not in self.lmgtfy_cache: if reaction.message.id not in self.lmgtfy_cache:
url = "https://lmddgtfy.net/?q=" + quote_plus(reaction.message.content) url = "https://lmddgtfy.net/?q=" + quote_plus(reaction.message.content)
m = await reaction.message.reply(f"[Here's the answer to your question]({url})") m = await reaction.message.reply(f"[Here's the answer to your question]({url})")
await m.edit(suppress=True) await m.edit(suppress=True)
self.lmgtfy_cache.append(reaction.message.id) self.lmgtfy_cache.append(reaction.message.id)
if reaction.emoji == "\N{wastebasket}": elif str(reaction.emoji)[0] == "\N{wastebasket}":
if reaction.message.channel.permissions_for(reaction.message.guild.me).manage_messages: if reaction.message.channel.permissions_for(reaction.message.guild.me).manage_messages:
self.log.info("Deleting message %s (Wastebasket)" % reaction.message.jump_url)
await reaction.message.delete( await reaction.message.delete(
reason="%s requested deletion of message" % user, reason="%s requested deletion of message" % user,
delay=0.2 delay=0.2
) )
else:
self.log.warning(
"Unable to delete message %s (wastebasket) - missing permissions",
reaction.message.jump_url
)
@commands.Cog.listener("on_raw_reaction_add") @commands.Cog.listener("on_raw_reaction_add")
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent): async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):