无法通过 id Discord.js 获取用户的用户名

时间:2021-03-16 22:08:24

标签: javascript discord.js

我尝试通过以下方式获取用户名:

client.users.cache.get(obj[message.author.id]["members"][i]).username

其中 obj 是解析的 JSON 文件, members 是字符串数组。控制台返回:

TypeError: Cannot read property 'username' of undefined

我 100% 确定 id 是正确的,我什至尝试将 var 设置为我想要获取用户名的 id 并且它有效,但是当与 obj[message.author.id]["members"][i] 一起使用时它不起作用.

0 个答案:

没有答案