#Best way to find and delete user messages

17 messages · Page 1 of 1 (latest)

abstract shoal
#

Hello there. So, as the title implies, I want to know what the best way to fetch ALL user messages and then delete them. My idea on how to go about this is to utilize the MessageManager.fetch({}) command to get all messages, filter them using messages.filter(m => m.author.id === USER_ID), and then using the TextChannel.bulkDelete() function and passing all the messages as an array.

Before putting this into practice though, I do have some questions. First and foremost is if this method is the most efficient. I don't want to waste resources and API calls when I don't need to, so is there a better way of going about this, or is this ultimately the best way? Also, will this method guarantee that I'll fetch ALL user messages, regardless of time passed, or will the filter only get the most recent ones? The command is responsible for deleting ALL user messages (well, I'll modify it to delete a specific number of messages in the future), so getting every message the user has sent (even if the first message was 2 years ago) is essential.

That is all. If someone could help me with my issue, that would be amazing. Thank you for your time and help, it is truly appreciated.

foggy juniper
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

brave vector
#

thats api spammy

abstract shoal
#

Also, will the MessageManager.fetch() return me all messages, or just whatever message is cached?

brave vector
#

it will return 100 messages

#

thats why you dont do it

#

you cant fetch all messages from a channel

abstract shoal
#

I see.

#

Well, that's unfortunate.

#

I intended to make a purge command similar to Dyno's, but I guess until Discord adds some type of message searching API (like how we can do Ctrl + F and filter through messages), there isn't much I can do.

#

Thank you for your help regardless, it is truly appreciated.

uncut kite
#

Dyno has a limit of 100 messages for the exact same reason… best way to delete a bulk of messages from a certain user is softban btw…

uncut kite
brave vector
#

True, thought they wanted for only one channel but they didnt actually mention anything about it