So That It SNIPES ONLY from a guild where the command is executed. 🥹 today I noticed that it also snipped the deleted messages from other guilds.
#Snipe History
#Snipe Command:
# Message delete event for snipe functionality
#Snipe History
snipedCormated=[]
#Snipe Command:
# Message delete event for snipe functionality
@bot.listen(hikari.GuildMessageDeleteEvent)
async def on_message_delete(event):
global snipeContent
global snipeAuthor
global snipedMessage
snipedMessage = {
"content": event.old_message.content,
"author": event.old_message.author,
"timestamp": event.old_message.timestamp
}
# Add the deleted message to the snipe list
snipedCormated.append(snipedMessage)
# If the snipe list has more than 5 elements, remove the oldest element
if len(snipedCormated) > 50:
snipedCormated.pop(0)
@bot.command
@lightbulb.add_checks(lightbulb.has_guild_permissions(hikari.Permissions.ADMINISTRATOR))
@lightbulb.option("number", "number", type=int)
@lightbulb.command("snipe", "snipes the last deleted message")
@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand)
async def snipe(ctx):
needofnum=0-ctx.options.number
message=snipedCormated[needofnum]
snipeEmbed=hikari.Embed(title="Snipped Message", description=f"Sniped Message Number: {str(ctx.options.number)}")
snipeEmbed.set_author(name=f"{str(message['author'])}")
snipeEmbed.add_field(name=":Endcystal: Deleted Message:", value=f"{str(message['content'])}")
snipeEmbed.add_field(name=":rgb: At:", value=f"{str(message['timestamp'])}")
await ctx.respond(embed=snipeEmbed)```