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

问题描述:

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

How do I make my bot mention someone on the server?

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

我以为它可以用,但不能用.还有另一种提及某人的方法吗?

I thought it would work but it doesn't. Is there another way to mention someone?

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

message.mentions.users.first() returns an object, which is why it's not working. This is the correct way to mention someone:

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


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


For future reference, here are the formats for all mentions:

'<@{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)