让不和谐的机器人提到某人

时间:2020-09-12 14:57:54

标签: javascript discord bots

如何让我的机器人在服务器上提及某人?

module.exports = {
 name: 'mention',
 description: 'this is a mention command!',
 execute(message) {
  mention = message.mentions.users.first();
  message.channel.send('Hello' + mention);
 },
};

我认为它会起作用,但不会。还有另一种提及某人的方法吗?

1 个答案:

答案 0 :(得分:1)

message.mentions.users.first()返回一个对象,这就是为什么它不起作用的原因。这是提及某人的正确方法:

mention = message.mentions.users.first();
message.channel.send(`Hello <@${mention.id}>`);

为便于将来参考,以下是所有提及的格式:

'<@{user.id}>' // user mention
'<#{channel.id}>' // channel mention
'<@&{role.id}>' // role mention
'<(a):{emoji.name}:{emoji.id}>' // emote (use 'a' at the front if emote is animated)