add more exception handling to on_message event
@@ -113,7 +113,11 @@ class Events(commands.Cog):
embed.set_author(name="Villager Bot", icon_url=self.d.splash_logo)
embed.set_footer(text=lang.misc.petus)
+ try:
await message.channel.send(embed=embed)
+ except (discord.errors.Forbidden, discord.errors.HTTPException):
+ pass
+
return
if message.guild is None:
@@ -151,15 +155,20 @@ class Events(commands.Cog):
]
if len(someones) > 0:
+ try:
await message.channel.send(
f"@someone {INVISIBLITY_CLOAK} {random.choice(someones).mention} {message.author.mention}"
)
+ except (discord.errors.Forbidden, discord.errors.HTTPException):
+ pass
+
return
if message.guild.id in self.bot.replies_cache:
prefix = self.bot.prefix_cache.get(message.guild.id, self.d.default_prefix)
if not message.content.startswith(prefix):
+ try:
if "emerald" in content_lower:
await message.channel.send(random.choice(self.d.hmms))
elif "creeper" in content_lower:
@@ -170,6 +179,8 @@ class Events(commands.Cog):
await message.channel.send(self.d.emojis.amogus)
elif content_lower == "good bot":
await message.reply(random.choice(self.d.owos), mention_author=False)
+ except (discord.errors.Forbidden, discord.errors.HTTPException):
+ pass
async def handle_cooldown(self, ctx, remaining: float, karen_cooldown: bool) -> None:
if ctx.command.name == "mine":
