0
votes

I'm not really experienced with discord.js and node.js but I want to know how I log DMs being sent to the bot to the console. This is the code I'm using to send messages to different people.

case 'senddm':
  mention = msg.mentions.users.first();
  msg.delete();
  if (mention == null) { return; }
  mentionMessage = msg.content.slice(9);
  mention.sendMessage(mentionMessage);
  console.log(`Send message: ${mentionMessage}`)
break;
1
What version of discord.js are you using? - Syntle
How do I check that? - Blenderer
check your package.json file - Syntle
I found this in "Package.json" [email protected] - Blenderer
Are you getting any errors? - Syntle

1 Answers

0
votes

You can check if your the id of the mentioned user is the same as your bot.

case 'senddm':
  mention = msg.mentions.users.first();
  msg.delete();
  if (mention == null) { return; }
  mentionMessage = msg.content.slice(9);
  mention.sendMessage(mentionMessage);

  if(mention.id === "your bot id here"){
      console.log(`Send message: ${mentionMessage}`)
  }
break;