“Discord.js bot menyebutkan” Kode Jawaban

Perselisihan JS Cara Menyebutkan 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

Periksa apakah pesan menyebutkan pengguna perselisihan JS

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

Perselisihan JS menyebutkan

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

Discord.js bot menyebutkan

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

cara membaca jika seseorang telah mengirim pesan di 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

Jawaban yang mirip dengan “Discord.js bot menyebutkan”

Pertanyaan yang mirip dengan “Discord.js bot menyebutkan”

Lebih banyak jawaban terkait untuk “Discord.js bot menyebutkan” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya