简体   繁体   中英

How to make my Discord Bot reply with a mention?

For example I want that someone sends in: "make my friend @FreezyGuy" Then my bot responds that: "making @FreezyGuy you friend is in progress..."

I even want my bot go back after 10 seconds and edit the message to: "@FreezyGuy is your friend now!"

If you can help with this second part you are awesome, but if you can with the mention that would be great as well.

client.on("message", function(message) {
  if (message.content === `make my friend` @mention) 
    if (message.author.bot) return;
    
    else if(message.content === `make my friend` @mention){
        message.channel.send(`making @mention your friend is in progress...`)
}});

Do you know how setTimeout works? I have this function that I use with my discord bot when getting mod applications.

    function waitmessage() {
        setTimeout(function(){msg.channel.send('This message waited 1 second to send!')}, 1000)
    }

The time is measured in milliseconds, so 1000 = 1 second. Once you have this function set up, you need to call the function later on in your code whenever you want to have this message to wait, for example:

msg.channel.send(waitmessage)

Which would make the bot start the function.

I believe the correct way to @ a user is by using <@[userID]>

For example Hello <@1234567890> to the server

As seen here: https://discordjs.guide/miscellaneous/parsing-mention-arguments.html#implementation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM