“Discord.js Bot Erwähnung” Code-Antworten

Discord JS wie man Bot erwähnt

//to mention bot you need the client.user
//like this

client.on('message' , message => {
	if(message.isMemberMentioned(client.user)) return message.channel.send(client.user)
})
//don't worry about the isMemberMentioned i only used it to make the bot detect if it's was mentioned
Open Oystercatcher

Überprüfen Sie, ob die Nachricht Benutzern Discord JS erwähnt

// 1st Way
if (<Message>.mentions.members.size) { // or message.mentions.members.size > 0
  //DO STUFF
}

// 2nd Way
if (<Message>.mentions.members.first()) {
  //DO STUFF
}
iKurasad

Zwietracht js erwähnt

// mention user:
msg = "Write to <@USERID>";
// mention role:
msg = "Dont ping <@&ROLEID>";
N!ls

Discord.js Bot Erwähnung

// We are going to use regex because its the best way to check
// client -> your discord.js Client variable

if (message.content.match(/^<@!?${client.user.id}>( |)$/)) 
  return message.channel.send("Hello! thanks for mentioning me!");
Concerned Cormorant

So lesen Sie, wenn eine Person eine Nachricht auf diskord.js senden hat

client.on('message', message => {
  // this function can check whether the content of the message you pass is the same as this message
  let filter = msg => {
    return msg.content.toLowerCase() == message.content.toLowerCase() && // check if the content is the same (sort of)
           msg.author == message.author; // check if the author is the same
  }

  message.channel.awaitMessages(filter, {
    maxMatches: 1, // you only need that to happen once
    time: 5 * 1000 // time is in milliseconds
  }).then(collected => {
    // this function will be called when a message matches you filter
  }).catch(console.error);
});
Crossed Face

Ähnliche Antworten wie “Discord.js Bot Erwähnung”

Fragen ähnlich wie “Discord.js Bot Erwähnung”

Weitere verwandte Antworten zu “Discord.js Bot Erwähnung” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen