aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-04-26 18:36:07 +0100
committerGravatar Chris Lovering <[email protected]>2022-08-19 10:28:02 +0100
commit5689ea0a8ad7e46a5c8f758b083b742d951cef40 (patch)
tree470b75e8f4bcfc91397a04a593ea2b8806882dc8
parentRemove need for additional abstraction in bookmark command (diff)
Add command to delete bot messages in DMs with sir-lancebot
-rw-r--r--bot/exts/utilities/bookmark.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/bot/exts/utilities/bookmark.py b/bot/exts/utilities/bookmark.py
index 32f6faa1..521a7bfa 100644
--- a/bot/exts/utilities/bookmark.py
+++ b/bot/exts/utilities/bookmark.py
@@ -75,7 +75,8 @@ class Bookmark(commands.Cog):
return
await channel.send(embed=error_embed)
- @commands.command(name="bookmark", aliases=("bm", "pin"))
+ @commands.group(name="bookmark", aliases=("bm", "pin"), invoke_without_command=True)
+ @commands.guild_only()
@whitelist_override(roles=(Roles.everyone,))
async def bookmark(
self,
@@ -146,6 +147,30 @@ class Bookmark(commands.Cog):
await reaction_message.delete()
+ @commands.dm_only()
+ @bookmark.command(name="delete", aliases=("del", "rm"), root_aliases=("unbm", "unbookmark", "dmdelete", "dmdel"))
+ async def delete_bookmark(
+ self,
+ ctx: commands.Context,
+ target_message: Optional[WrappedMessageConverter]
+ ) -> None:
+ """
+ Delete the referenced DM message by the member.
+
+ Members can either give a message as an argument, or reply to a message.
+ This allows deleting any message in the user's DM with sir-lancebot.
+ """
+ target_message: Optional[discord.Message] = target_message or getattr(ctx.message.reference, "resolved", None)
+ if target_message is None:
+ raise commands.UserInputError(MESSAGE_NOT_FOUND_ERROR)
+
+ if target_message.channel != ctx.channel:
+ raise commands.UserInputError(":x: You can only delete messages in your own DMs!")
+ elif target_message.author != self.bot.user:
+ raise commands.UserInputError(":x: You can only delete messages sent by Sir Lancebot!")
+
+ await target_message.delete()
+
def setup(bot: Bot) -> None:
"""Load the Bookmark cog."""