简体   繁体   中英

Discord.js Bot Reaction Command with gif

I want that if someone types in the command .hello (ping user) , that there is a gif in an embed which shows that expression. My problem now is that I dont know how to this with a different user than myself. So I can type .hello and then there is my Discord Username and the gif, but I dont know how that works with other users. I hope someone can help me.

Code:

client.on("message", (message) => {
    var user = message.mention.member;
    if (message.content == ".retarded" + user) {
        
         const retarded = new Discord.MessageEmbed()
           .setColor('#000033')
           .addFields(
              { name: user , value: "Text" },
           )
           .setImage(
               "https://media.tenor.com/images/782baae8b076ea2e1ffd7ab7f0df8010/tenor.gif"
           )
           .setTimestamp()
           .setFooter(message.author.username);

        message.channel.send(retarded)
        console.log(message.member.user.tag +' executed command .RETARDED')
    }
})


    
client.login(config.token)

If you want to get the User or a GuildMember usingmentions , you can try:

message.mentions.users.first() //User

or

message.mentions.members.first() //GuildMember

which will return the first entry in the collection. You can store them, and access the properties and methods of that object.

Note:- GuildMember and User are different from each other.

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