bugfix: cannot add reaction to interactions, add exception handling/stop sending related errors to discord context

This commit is contained in:
codey 2025-03-14 06:33:50 -04:00
parent 97808e388f
commit 3bb1ea8ccc

View File

@ -1088,7 +1088,11 @@ class Misc(commands.Cog):
recipient = discord.utils.escape_mentions(recipient.strip()) recipient = discord.utils.escape_mentions(recipient.strip())
try: try:
response = await ctx.respond(f"*hands **{recipient_normal}** a muffin*") response = await ctx.respond(f"*hands **{recipient_normal}** a muffin*")
await response.add_reaction(emoji="<:muffin:1314233635586707456>") try:
await response.add_reaction(emoji="<:muffin:1314233635586707456>")
except Exception as e:
logging.debug("Failed to add muffin reaction: %s",
str(e)) # known: cannot react to interaction
await self.util.increment_counter("muffins") await self.util.increment_counter("muffins")
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
@ -1129,7 +1133,11 @@ class Misc(commands.Cog):
recipient = discord.utils.escape_mentions(recipient.strip()) recipient = discord.utils.escape_mentions(recipient.strip())
try: try:
response = await ctx.respond(f"*hands **{recipient_normal}** a side of bacon*") response = await ctx.respond(f"*hands **{recipient_normal}** a side of bacon*")
await response.add_reaction(emoji="🥓") try:
await response.add_reaction(emoji="🥓")
except Exception as e:
logging.debug("Failed to add bacon reaction: %s",
str(e)) # known: cannot react to interactions
await self.util.increment_counter("bacon_sides") await self.util.increment_counter("bacon_sides")
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
@ -1444,8 +1452,9 @@ class Misc(commands.Cog):
await self.util.increment_counter("coffees") await self.util.increment_counter("coffees")
try: try:
await response.add_reaction(emoji="") await response.add_reaction(emoji="")
except: except Exception as e:
pass logging.debug("Failed to add coffee reaction: %s",
str(e)) # known: cannot react to interaction
def cog_unload(self) -> None: def cog_unload(self) -> None:
"""Run on Cog Unload""" """Run on Cog Unload"""