Skip to content

Commit

Permalink
fix: suppress forbidden exceptions in listeners (#129)
Browse files Browse the repository at this point in the history
we don't actually care if we can send messages
potentially we can disable them for the user if they revoke permissions
  • Loading branch information
NiceAesth authored Feb 7, 2024
1 parent 319a907 commit 9d57873
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/listeners/osulisteners.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
###
from __future__ import annotations

from contextlib import suppress
from io import BytesIO
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -86,11 +87,12 @@ async def beatmap_listener(self, message: discord.Message) -> None:
return

await self.bot.beatmap_service.add(ctx.channel.id, beatmapset.beatmaps[0])
await OsuBeatmapView.start(
ctx,
beatmapset,
file=audio_file,
)
with suppress(discord.Forbidden):
await OsuBeatmapView.start(
ctx,
beatmapset,
file=audio_file,
)

async def user_listener(self, message: discord.Message) -> None:
user_id = get_user_from_text(message.content)
Expand All @@ -106,7 +108,8 @@ async def user_listener(self, message: discord.Message) -> None:

graph = await self.get_graph(user, int(user.playmode))
embed.set_image(url="attachment://rank_graph.png")
await ctx.send(embed=embed, file=discord.File(graph, "rank_graph.png"))
with suppress(discord.Forbidden):
await ctx.send(embed=embed, file=discord.File(graph, "rank_graph.png"))


async def setup(bot: Sunny) -> None:
Expand Down

0 comments on commit 9d57873

Please sign in to comment.