Skip to content

Commit

Permalink
make delete bm a ctx menu cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrou Bellalouna authored and shtlrs committed Feb 22, 2023
1 parent 422cb58 commit d2f9bc4
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions bot/exts/utilities/bookmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self, bot: Bot):
callback=self._delete_bookmark_context_menu_callback,
)
self.bot.tree.add_command(self.book_mark_context_menu, guild=discord.Object(bot.guild_id))
self.bot.tree.add_command(self.delete_book_mark_context_menu)

@staticmethod
def build_success_reply_embed(target_message: discord.Message) -> discord.Embed:
Expand Down Expand Up @@ -147,7 +148,7 @@ async def _bookmark_context_menu_callback(self, interaction: discord.Interaction
@whitelist_override(roles=(Roles.everyone,))
@commands.cooldown(1, 30, commands.BucketType.channel)
async def bookmark(self, ctx: commands.Context) -> None:
"""Teach the invoker how to use the new context-menu based command for a smooth migration."""
"""Teach the invoker how to use the new bookmark context-menu based command for a smooth migration."""
await ctx.send(
embed=self.build_error_embed(
"The bookmark text command has been replaced with a context menu command!\n\n"
Expand All @@ -162,24 +163,14 @@ async def delete_bookmark(
self,
ctx: commands.Context,
) -> None:
"""
Delete the Sir-Lancebot message that the command invocation is replying to.
This command allows deleting any message sent by Sir-Lancebot in the user's DM channel with the bot.
The command invocation must be a reply to the message that is to be deleted.
"""
target_message: Optional[discord.Message] = getattr(ctx.message.reference, "resolved", None)
if target_message is None:
raise commands.UserInputError("You must reply to the message from Sir-Lancebot you wish to delete.")

if not isinstance(ctx.channel, discord.DMChannel):
raise commands.UserInputError("You can only run this command your own DMs!")
elif target_message.channel != ctx.channel:
raise commands.UserInputError("You can only delete messages in your own DMs!")
elif target_message.author != self.bot.user:
raise commands.UserInputError("You can only delete messages sent by Sir Lancebot!")

await target_message.delete()
"""Teach the invoker how to use the new delete bookmark context-menu based command for a smooth migration."""
await ctx.send(
embed=self.build_error_embed(
"The delete bookmark text command has been replaced with a context menu command!\n\n"
"To delete a bookmark simply right-click (press and hold on mobile) "
"on a bookmark message, open the 'Apps' menu, and click 'Delete bookmark'."
)
)


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

0 comments on commit d2f9bc4

Please sign in to comment.