【发布时间】:2020-06-12 03:55:42
【问题描述】:
这不起作用:
client.users.cache.get(`${args[0]}`).id;
我应该怎么做才能修复它?我在 v12 上
【问题讨论】:
-
它返回这个错误信息:
TypeError: message.client.users.find is not a function
标签: javascript node.js discord discord.js
这不起作用:
client.users.cache.get(`${args[0]}`).id;
我应该怎么做才能修复它?我在 v12 上
【问题讨论】:
TypeError: message.client.users.find is not a function
标签: javascript node.js discord discord.js
试试
matching_client = client.users.cache.filter(user => user.username === args[0]);
matching_client 是与该用户名匹配的用户集合
相关文档链接:
https://discord.js.org/#/docs/collection/master/class/Collection?scrollTo=filter
【讨论】:
votefor = message.client.users.cache.filter(user => user.username === args[0]); id = votefor.id; 但返回未定义
id = votefor.array()[0].id
<Collection>.find()?这样您就不必将其转换为数组,也不必按 0 对其进行索引。