[英]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.我希望如果有人输入命令
.hello (ping user)
,嵌入中会有一个 gif 来显示该表达式。 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.所以我可以输入
.hello
然后是我的 Discord 用户名和 gif,但我不知道它如何与其他用户一起使用。 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:如果您想使用提及来获取用户或 GuildMember,您可以尝试:
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.
您可以存储它们,并访问该 object 的属性和方法。
Note:- GuildMember and User are different from each other.注意:- GuildMember 和 User 彼此不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.