“discord.js bot mention” Réponses codées

Discord JS Comment mentionner le bot

//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

Vérifiez si le message mentionne Discord JS des utilisateurs

// 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

Discord JS Mention

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

discord.js bot mention

// 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

Comment lire si une personne a envoyé un message sur Discord.js

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

Réponses similaires à “discord.js bot mention”

Questions similaires à “discord.js bot mention”

Plus de réponses similaires à “discord.js bot mention” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code