I want to try to fix this error, but I have no clue on how the code im using:
const rainPerms = [
"MANAGE_ROLES",
"ADMINISTRATOR"
];
let place = 0;
const servers = ["111111111111111111", "222222222222222222"] //fake ID
const Guilds = client.guilds.cache.map(guild => guild.id);
const Server = Guilds
function changeColor() {
for (let index = 0; index < servers.length; ++index) {
let server = client.guilds.cache.get(servers[index]);
let role = server.roles.cache.find(r => r.name === 'Rainbow');
role.setColor(rainbow[place]).catch;
if (!rainPerms) {
}
continue;
}
}
if (place == (size - 1)) {
place = 0;
} else {
place++;
}
client.on('ready', () => {
setInterval(changeColor, 60000);
changeColor();
});
and my error is:
let role = server.roles.cache.find(r => r.name === 'Rainbow');
^
TypeError: Cannot read property 'roles' of undefined
I have searched all over and I could not find much that I could understand, could someone please explain what exactly is going on here? thanks!
I would not recommend using roles cache if you're using v12/v13, instead use an async function.
To get guild:
let guild = await client.guilds.fetch('id')
And to get a role:
let role = await guild.roles.fetch('id')