mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
Add undelete command
This commit is contained in:
parent
e13363b877
commit
f7c7a6ad9f
1 changed files with 39 additions and 0 deletions
39
cogs/mod.py
39
cogs/mod.py
|
@ -94,6 +94,45 @@ class Mod(commands.Cog):
|
||||||
await entry.delete()
|
await entry.delete()
|
||||||
await ctx.respond(f"\N{white heavy check mark} Unblocked {user.mention}.")
|
await ctx.respond(f"\N{white heavy check mark} Unblocked {user.mention}.")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def undelete(self, ctx: commands.Context, user: discord.User, *, query: str = None):
|
||||||
|
"""Searches through the message cache to see if there's any deleted messages."""
|
||||||
|
for message in self.bot.cached_messages:
|
||||||
|
message: discord.Message
|
||||||
|
if message.author == user:
|
||||||
|
query_ = query.lower() if query else None
|
||||||
|
content_ = str(message.clean_content).lower()
|
||||||
|
if query_ is not None and query_ in content_ or content_ in query_:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return await ctx.reply("\N{cross mark} No matches in cache.")
|
||||||
|
|
||||||
|
embeds = [
|
||||||
|
discord.Embed(title="Message found!"),
|
||||||
|
discord.Embed(
|
||||||
|
description=message.content,
|
||||||
|
colour=message.author.colour,
|
||||||
|
timestamp=message.created_at,
|
||||||
|
fields=[
|
||||||
|
discord.EmbedField(
|
||||||
|
"Attachment count",
|
||||||
|
str(len(message.attachments)),
|
||||||
|
False
|
||||||
|
),
|
||||||
|
discord.EmbedField(
|
||||||
|
"Location",
|
||||||
|
str(message.channel.mention)
|
||||||
|
),
|
||||||
|
discord.EmbedField(
|
||||||
|
"Times",
|
||||||
|
f"Created: {discord.utils.format_dt(message.created_at, 'R')} | Edited: "
|
||||||
|
f"{'None' if message.edited_at is None else discord.utils.format_dt(message.edited_at, 'R')}"
|
||||||
|
)
|
||||||
|
]
|
||||||
|
).set_author(name=message.author.display_name, icon_url=message.author.display_avatar.url)
|
||||||
|
]
|
||||||
|
await ctx.reply(embeds=embeds)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Mod(bot))
|
bot.add_cog(Mod(bot))
|
||||||
|
|
Loading…
Reference in a new issue