Role cache get undefined
const guild = client.guilds.cache.get('929288640142663720');
let roles = [];
if (config.admin_role) {
config.admin_role.forEach(async (role) => {
console.log(role);
const roleFetched = guild.roles.cache.get(role);
console.log(roleFetched);
if (!roleFetched) return roles.push('[INVALID ROLE]');
roles.push(roleFetched);
await channel.permissionOverwrites.create(roleFetched.id, {
SendMessages: true,
ViewChannel: true,
AttachFiles: true,
AddReactions: true,
EmbedLinks: true,
ReadMessageHistory: true
})
});
} else {
roles.push("No roles were added to config.js file.");
} const guild = client.guilds.cache.get('929288640142663720');
let roles = [];
if (config.admin_role) {
config.admin_role.forEach(async (role) => {
console.log(role);
const roleFetched = guild.roles.cache.get(role);
console.log(roleFetched);
if (!roleFetched) return roles.push('[INVALID ROLE]');
roles.push(roleFetched);
await channel.permissionOverwrites.create(roleFetched.id, {
SendMessages: true,
ViewChannel: true,
AttachFiles: true,
AddReactions: true,
EmbedLinks: true,
ReadMessageHistory: true
})
});
} else {
roles.push("No roles were added to config.js file.");
}When i using this it backs undefined how could i get the role