Best way to find and delete user messages
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
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.
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.