无法读取未定义的属性“角色”

时间:2020-04-18 18:20:52

标签: node.js ejs

我已经尝试了所有会不断出现此错误的问题,我的所有软件包都是最新的,我已经一遍又一遍地验证了这一点,

 >> 301|            <%

    302|         const roles = guild.cache.roles;

    303|         roles.forEach(r => {

    304|            %>```

Cannot read property 'roles' of undefined
    at eval (/root/Hosted/Bot/dashboard/guild/manage.ejs:256:35)
    at manage (/root/Hosted/Bot/node_modules/ejs/lib/ejs.js:682:17)
    at tryHandleCache (/root/Hosted/Bot/node_modules/ejs/lib/ejs.js:254:36)
    at View.exports.renderFile [as engine] (/root/Hosted/Bot/node_modules/ejs/lib/ejs.js:485:10)
    at View.render (/root/Hosted/Bot/node_modules/express/lib/view.js:135:8)
    at tryRender (/root/Hosted/Bot/node_modules/express/lib/application.js:640:10)
    at Function.render (/root/Hosted/Bot/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/root/Hosted/Bot/node_modules/express/lib/response.js:1012:7)
    at renderTemplate (/root/Hosted/Bot/modules/dashboard.js:38:9)
    at /root/Hosted/BetaBot/modules/dashboard.js:214:5
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

1 个答案:

答案 0 :(得分:0)

如果guild是公会,而不是公会的集合,那么您想要的是guild.roles.cache,而不是guild.cache.roles,只是有些人感到困惑,v12让人很难理解。