【问题标题】:Making discord bot mention someone让不和谐的机器人提到某人
【发布时间】:2020-12-30 20:06:48
【问题描述】:

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

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

我认为它会起作用,但它没有。还有其他方式来提及某人吗?

【问题讨论】:

    标签: javascript discord bots


    【解决方案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)
    

    【讨论】:

    猜你喜欢
    • 2018-11-06
    • 2021-03-31
    • 2020-11-18
    • 2020-05-18
    • 2018-08-21
    • 1970-01-01
    • 2018-03-20
    • 2023-04-04
    • 1970-01-01
    相关资源
    最近更新 更多