Cannot read property 'members' of undefined

I’m trying to kind of make a ,kill command for a discord bot. Every time I try and run it, it comes out with

TypeError: Cannot read property ‘members’ of undefined

client.on("message", message => {
  if (message.content.startsWith(prefix + "kill")) {
    let user = message.mention.members.first();
    let messanger = message.member;
    message.channel.send(messanger.username + "oofed" + "<@" + user.id + ">");
  }
});

Does anyone know why this is happening and how to fix it?

Discord V12

it should be message.mentions . Minor typo in “messanger” if you feel like correcting that as well.

he defined messanger here

I pointed out as an aside that he misspelled the variable “messenger” as “messanger” but it can be left that way if he prefers it.

If you are using the latest release of discord.js, there is no .mention property in a message object (as far as I know, there were never so I think its just a mispell. But I’m not sure).

You want to use .mentions described here.
For an implementation example, see this guide here.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.