diff --git a/nomen/notifications.py b/nomen/notifications.py index f1a0bf3..b69a4f3 100644 --- a/nomen/notifications.py +++ b/nomen/notifications.py @@ -5,6 +5,7 @@ from typing import Union from disnake import Embed, Member, Thread, User from disnake.abc import GuildChannel +from disnake.errors import Forbidden from disnake.ext.commands import Cog, group, guild_only from .utils import can_view, confirm, test_keyword @@ -64,10 +65,16 @@ async def handle_notification(db_updates, ctx, message, keyword, user_id, use_em icon_url=message.author.display_avatar, ) - await member.send(header, embed=embed) + try: + await member.send(header, embed=embed) + except Forbidden: + log.warning("Cannot send messages to this user") else: log.debug("Sending plain message") - await member.send("\n".join((header, indent(message.content, "> ", lambda line: True).strip(), footer))) + try: + await member.send("\n".join((header, indent(message.content, "> ", lambda line: True).strip(), footer))) + except Forbidden: + log.warning("Cannot send messages to this user") log.debug("Sent")