how do I get my bot to say who deleted the message?

how do I get my bot to say who deleted the message?

Problem Description:

So I was following various guides, and I built this message create event but was having a problem getting it to say who sent the message.

Here is my code

badword = ['test']

client.on('messageCreate', (message) => {
    if (message.content == badword){
        .then(msg => console.log(`Deleted message from ${}`))

And the console log

Deleted message from undefined

I was also wondering if I could make it get rid of any message that includes the word instead of the message being strictly ‘test’.

Solution – 1

The correct way to access the tag is just, because user.username is just a string and not an object. Here’s the User object from the discord.js docs.

So your console.log statement should just be:

console.log(`Deleted message from ${}`)
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.