首页 > 解决方案 > 我无法在 discord.js 中获得公会名称

问题描述

公会名我查不出来 奇怪的是代码在其他文件中运行良好,我不知道问题出在哪里。请帮忙!PS。player.guild工作正常。我用 console.log 对其进行了测试,它返回了公会 ID,所以我不知道问题所在。PSS。我正在使用 discord.js v12 代码:

const gd = bot.guilds.cache.get(player.guild).name
console.log(gd)

错误是:

TypeError: Cannot read property 'name' of undefined

标签: node.jsdiscord.js

解决方案


推荐阅读