Deleting someone's messages when they leave the server [discord.js]

Hello!

Using discord.js, how do I make the bot delete someone’s messages in a specific channel when they leave the server?

Hm, I’m not too sure on how to do that. But I do know that you cannot delete messages older than 14 days. Might wanna take this into consideration! @Coderholic
-Happy Glitching tech_dude1

1 Like

Yep, I am aware. Thanks, though!

You’d need to log messages sent by the user as the GuildMember object doesn’t have a property or method to getting the messages sent by the user.

1 Like

How would I do that?

I know that banning a member deletes messages, and I know that you can ban someone who isn’t in the server. :thinking:

1 Like

Use the member leave event, then use discord.js.org website to see how to prune/purge their messages in a certain channel.

This might help, I’m not giving you straight up code, learning is something that takes you far! :smiley: