[英]How mention on discord.js
請幫忙,如何在消息中提及用戶? 我在網上找不到答案。 我的代碼:
const exampleeEmbedd = new MessageEmbed()
.setColor('#53db56')
.setTitle(' [👋] Приветствуем нового путника!')
.setDescription(' Приветствуем вас ' + /*MENTION*/ + '!\nДобро пожаловать на международный сервер режима Geopolitics. \nЗдесь вы можете присоеденится к существующему городу/государству, либо зарегистрировать свой город/государство.')
.setURL('')
.setAuthor('👑Имперский Бот👑', 'https://images-ext-2.discordapp.net/external/nWASMV-67mx7guRheeUpvyD_cb6X2NkxUMH4PtbweyA/%3Fsize%3D512/https/cdn.discordapp.com/avatars/916617120064884796/5028d4861b407575072686657b3c2e9a.png' )
.setThumbnail(user.avatarURL())
.addFields(
)
.setImage('')
.setTimestamp()
.setFooter('asdas', 'https://images-ext-2.discordapp.net/external/nWASMV-67mx7guRheeUpvyD_cb6X2NkxUMH4PtbweyA/%3Fsize%3D512/https/cdn.discordapp.com/avatars/916617120064884796/5028d4861b407575072686657b3c2e9a.png');
mess.channel.send( { embeds: [exampleeEmbedd] } );
Discord.js 在解釋為字符串時會自動為您轉換提及。
"Foo" + user + "Bar"
轉換為Foo<@!1234567890>Bar
。
使用模板字符串:
`Foo${user}Bar`
如果您只有用戶 ID,您可以手動執行此操作:
"Foo<@!" + userId + ">Bar"
// or
`Foo<@!${userId}>Bar`
確保userId
是一個字符串。
您需要使用${user}
字符串或${user.tag}
,因此您的機器人將提及用戶。
確保將let user = message.mentions.members.first()
放置在嵌入上方
這個例子:
const exampleeEmbed = new MessageEmbed()
.setTitle('an embed')
.setDescription(`Hello ${user}!`)
mess.channel.send({ embeds: exampleeEmbed });
還要確保將您的消息``
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.