0
votes

I am trying to create a command that deletes a specific user's last message, so if 5 users sent 5 messages, I could use !>discard <usermention> (let's say the 3rd user) to delete user 3's last message.

I am having trouble with setting this command up and currently don't know how to make it with the skills I currently have.

1

1 Answers

0
votes

You could have the on_message(msg): event that would place every message into a global list (maybe even a .txt file if you want to prevent losing the list when the bot shuts down)

@client.event
async def on_ready():
    global messageList = []

@client.event
async def on_message(msg):
    global messageList
    messageList.append(msg)

And then delete the one you want with a command

@client.command()
async def discard(*args):
    del messageList[int(args[0])+1]