【问题标题】:I'm trying to fetch members from a guild using their ID but now the variable I'm using returns Undefined我正在尝试使用他们的 ID 从公会中获取成员,但现在我使用的变量返回未定义
【发布时间】:2021-05-16 11:45:37
【问题描述】:

一小时前一切正常,但现在 discord.js 拒绝使用他们的 ID 从公会中获取成员。

let target = message.guild.members.cache.get(args[0])

从它开始工作时我根本没有改变任何东西。 我不知道这是怎么发生的,但我很困惑。

注意args[0] 是一个字符串。来自消息中第一个参数的用户 ID。

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    我不确定它是如何工作的。 .cache 属性上没有 .fetch() 方法,它返回一个承诺,所以你需要 await 成员:

    let target = await message.guild.members.fetch(args[0]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-26
      • 1970-01-01
      • 2021-05-23
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      相关资源
      最近更新 更多