From 0dae917e3d02b46296c2087edd2b7ec108ab55f4 Mon Sep 17 00:00:00 2001 From: Amrou Bellalouna Date: Sun, 15 Jan 2023 13:00:47 +0100 Subject: disallow usage of the context menu command in DMs --- bot/exts/utilities/bookmark.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bot') diff --git a/bot/exts/utilities/bookmark.py b/bot/exts/utilities/bookmark.py index 473ecedc..e2988dca 100644 --- a/bot/exts/utilities/bookmark.py +++ b/bot/exts/utilities/bookmark.py @@ -180,6 +180,11 @@ class Bookmark(commands.Cog): async def _bookmark_context_menu_callback(self, interaction: discord.Interaction, message: discord.Message) -> None: """The callback that will be invoked upon using the bookmark's context menu command.""" permissions = interaction.channel.permissions_for(interaction.user) + if not interaction.channel.guild: + embed = Bookmark.build_error_embed("This command cannot be used in DMs.") + await interaction.response.send_message(embed=embed) + return + if not permissions.read_messages: log.info(f"{interaction.user} tried to bookmark a message in #{interaction.channel}" f"but has no permissions.") -- cgit v1.2.3