Silently ignore db deletion errors, closes #134

This commit is contained in:
Zeva Rose 2022-04-19 16:01:29 -06:00
parent f5cba3ce3a
commit 6c1753d5d2
4 changed files with 17 additions and 5 deletions

View file

@ -67,7 +67,10 @@ class RolepingCog(Scale):
await ctx.send("Roleping does not exist", ephemeral=True) await ctx.send("Roleping does not exist", ephemeral=True)
return return
await roleping.delete() try:
await roleping.delete()
except Exception:
self.logger.debug("Ignoring deletion error")
await ctx.send(f"Role `{role.name}` removed from roleping.") await ctx.send(f"Role `{role.name}` removed from roleping.")
@roleping.subcommand(sub_cmd_name="list", sub_cmd_description="Lick all blocklisted roles") @roleping.subcommand(sub_cmd_name="list", sub_cmd_description="Lick all blocklisted roles")
@ -190,6 +193,9 @@ class RolepingCog(Scale):
async def _roleping_bypass_role( async def _roleping_bypass_role(
self, ctx: InteractionContext, bypass: Role, role: Role self, ctx: InteractionContext, bypass: Role, role: Role
) -> None: ) -> None:
if bypass.id == ctx.guild.id:
await ctx.send("Cannot add `@everyone` as a bypass", ephemeral=True)
return
roleping = await Roleping.find_one(q(guild=ctx.guild.id, role=role.id)) roleping = await Roleping.find_one(q(guild=ctx.guild.id, role=role.id))
if not roleping: if not roleping:
await ctx.send(f"Roleping not configured for {role.mention}", ephemeral=True) await ctx.send(f"Roleping not configured for {role.mention}", ephemeral=True)

View file

@ -279,7 +279,7 @@ class RemindmeCog(Scale):
try: try:
await reminder.delete() await reminder.delete()
except Exception: except Exception:
pass # Silently drop error self.logger.debug("Ignoring deletion error")
for row in components: for row in components:
for component in row.components: for component in row.components:
@ -333,7 +333,7 @@ class RemindmeCog(Scale):
try: try:
await reminder.delete() await reminder.delete()
except Exception: except Exception:
pass # Silently drop error self.logger.debug("Ignoring deletion error")
def setup(bot: Snake) -> None: def setup(bot: Snake) -> None:

View file

@ -141,7 +141,10 @@ class StarboardCog(Scale):
to_delete.append(starboard) to_delete.append(starboard)
for starboard in to_delete: for starboard in to_delete:
await starboard.delete() try:
await starboard.delete()
except Exception:
self.logger.debug("Ignoring deletion error")
select_channels = [] select_channels = []
for idx, x in enumerate(channel_list): for idx, x in enumerate(channel_list):

View file

@ -150,7 +150,10 @@ class TwitterCog(Scale):
) )
for to_delete in context.context.values: for to_delete in context.context.values:
follow = get(twitters, guild=ctx.guild.id, twitter_id=int(to_delete)) follow = get(twitters, guild=ctx.guild.id, twitter_id=int(to_delete))
await follow.delete() try:
await follow.delete()
except Exception:
self.logger.debug("Ignoring deletion error")
for row in components: for row in components:
for component in row.components: for component in row.components:
component.disabled = True component.disabled = True