How do i set permission override

Im trying to do
channel.permissionOverwrites.edit(roleId, { ViewChannel: false });
channel.permissionOverwrites.edit(roleId, { ViewChannel: false });
but seems like permissionOverwrites does not exist (undefined)?
13 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Luxbug
LuxbugOP7mo ago
14.15.2 i cant access permissionOverwrites on any channel type
Svitkona
Svitkona7mo ago
can you show how you defined channel
Amgelo
Amgelo7mo ago
if the error is "cannot read properties of undefined (reading permissionOverwrites)", then channel is undefined, not permissionOverwrites
Luxbug
LuxbugOP7mo ago
Nah says edit is undefined So permission override is undefined I tried all channel types idk whats the problem
TÆMBØ
TÆMBØ7mo ago
Please share the full error rather than paraphrasing it
Luxbug
LuxbugOP7mo ago
Ok…1 sec
Amgelo
Amgelo7mo ago
and also what Svitkona mentioned, how are you defining channel
Luxbug
LuxbugOP7mo ago
so its in a loop
const guild = await client.guilds.fetch("945412046072209408");

for (const channel of guild.channels.cache.values()) {
if (!channel.isTextBased()) continue;

if (!channel.manageable) continue;

channel.permissionOverwrites.edit("", { ViewChannel: false });
}
const guild = await client.guilds.fetch("945412046072209408");

for (const channel of guild.channels.cache.values()) {
if (!channel.isTextBased()) continue;

if (!channel.manageable) continue;

channel.permissionOverwrites.edit("", { ViewChannel: false });
}
Property 'permissionOverwrites' does not exist on type 'NewsChannel | StageChannel | TextChannel | PrivateThreadChannel | PublicThreadChannel<boolean> | VoiceChannel'. Property 'permissionOverwrites' does not exist on type 'PrivateThreadChannel'.
Amgelo
Amgelo7mo ago
well as the error says, private threads don't have a permission overwrites
d.js docs
d.js docs7mo ago
:method: BaseChannel#isThread @14.15.2 Indicates whether this channel is a ThreadChannel.
TÆMBØ
TÆMBØ7mo ago
Add this typeguard along with your other one to exclude threads
Luxbug
LuxbugOP7mo ago
same thing if (!channel.isThread()) continue; channel.permissionOverwrites.edit("", { ViewChannel: false }); wait sorryu ! was the problem ty for ur help
Want results from more Discord servers?
Add your server