【问题标题】:How to mention a user mentioned in the command discord js如何提及命令 discord js 中提到的用户
【发布时间】:2021-04-13 15:51:46
【问题描述】:

所以我正在研究一个不和谐的机器人,并在一个提到用户的命令上工作。例如:-fakekick @user 机器人会说 User has been kicked 我已经阅读了文档并找到了一些站点,但我无法真正理解它,因为我几天前才开始使用 discord js。谢谢

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    要获取提到的用户的用户对象,您可以非常简单地使用message 对象的mentions 扩展。我们可以非常简单地使用它来定义我们的用户,然后在以后的消息中提及他。这可以非常简单地完成:

    const user = message.mentions.users.first(); // Would get the first mentioned user's object
    message.channel.send(`${user} has been kicked!`); // To mention a user, you simply need to mention his user object.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-07
      • 2021-12-20
      • 2021-07-26
      • 2021-05-16
      • 2021-08-05
      • 1970-01-01
      • 2020-07-27
      • 2021-10-24
      相关资源
      最近更新 更多