我希望机器人能够改变角色的颜色而且会出错
client.guilds.get(servers[index]).roles.find('name', config.roleName).setColor(rainbow[place])
^
TypeError: Cannot read property 'roles' of undefined
at Timeout.changeColor [as _onTimeout] (C:\Users\1\Desktop\discord1\Role.js:29:38)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5)
这是我的代码:
function changeColor() {
for (let index = 0; index < servers.length; ++index) {
client.guilds.get(servers[index]).roles.find('name', config.roleName).setColor(rainbow[place])
.catch(console.error);
if(config.logging){
console.log([ColorChanger] Changed color to ${rainbow[place]} in server: ${servers[index]});
}
if(place == (size - 1)){
place = 0;
}else{
place++;
}
}
}