Listing new permissions with channelCreate event - permissionOverwrites

Hello there! I have a log on Discord.JS v12 that is fired on the channelCreate event, where it logs some information from that creation, as well as the users & roles that have access to it. This code works on v12, however when trying to convert it to v14 I run into a few errors. If I use the original code with channel.permissionOverwrites.cache.map(perms => perms) it says that channel.permissionOverwrites.map is not a function. So I changed it to channel.permissionOverwrites.cache.map and now it errors trying to create the Field for the Embed. This is the error below, as well as the code.
let rolearray = [];
let role1;
let rolelist = await channel.permissionOverwrites.cache.map(perms => perms)//.join(',\n');
rolelist.forEach(r => {
if(r.type === 'role'){
let roleid = r.id;
role1 = channel.guild.roles.cache.get(roleid)
rolearray.push(`${role1}`)
}
else if(r.type === 'member'){
let roleid = r.id;
role1 = client.users.cache.get(roleid)
rolearray.push(`${role1}`)
}
})


let embed = new EmbedBuilder()
.setAuthor({ name: `${creatorTag} Created a Channel`, iconURL: `${executor.displayAvatarURL()}` })
.setColor("Green")
.addFields({ name: `Information:`, value: `Name: **${newChan}**\nCategory: **${cat}**\nType: **${type}**\nCreated By: **${executor}**`, inline: false })
.addFields({ name: `Permissions: (${rolearray.length})`, value: `${rolearray}`, inline: false })
.setTimestamp()
.setFooter({ text: `ID: ${creatorID} | Extra Life Roleplay`, iconURL: `${client.user.displayAvatarURL()}` })

await loggingChannel.send({ embeds: [embed] });
let rolearray = [];
let role1;
let rolelist = await channel.permissionOverwrites.cache.map(perms => perms)//.join(',\n');
rolelist.forEach(r => {
if(r.type === 'role'){
let roleid = r.id;
role1 = channel.guild.roles.cache.get(roleid)
rolearray.push(`${role1}`)
}
else if(r.type === 'member'){
let roleid = r.id;
role1 = client.users.cache.get(roleid)
rolearray.push(`${role1}`)
}
})


let embed = new EmbedBuilder()
.setAuthor({ name: `${creatorTag} Created a Channel`, iconURL: `${executor.displayAvatarURL()}` })
.setColor("Green")
.addFields({ name: `Information:`, value: `Name: **${newChan}**\nCategory: **${cat}**\nType: **${type}**\nCreated By: **${executor}**`, inline: false })
.addFields({ name: `Permissions: (${rolearray.length})`, value: `${rolearray}`, inline: false })
.setTimestamp()
.setFooter({ text: `ID: ${creatorID} | Extra Life Roleplay`, iconURL: `${client.user.displayAvatarURL()}` })

await loggingChannel.send({ embeds: [embed] });
6 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
cqllin
cqllinOP2y ago
- npm 8.19.2
- npm 8.19.2
The top bit of the console ^^^ is just me running
console.log(channel.permissionOverwrites)
console.log(channel.permissionOverwrites)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
cqllin
cqllinOP2y ago
Wdym fields no longer work like that? That is exactly how the docs have it Anyways, got it to work. Thanks
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
cqllin
cqllinOP2y ago
Well it worked just like that lol. The issue was with the way the permissionOverwrites was setup That is how I code all of my embeds
Want results from more Discord servers?
Add your server