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 toolkit•6mo 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
Luxbug•6mo ago
14.15.2 i cant access permissionOverwrites on any channel type
Svitkona
Svitkona•6mo ago
can you show how you defined channel
Amgelo
Amgelo•6mo ago
if the error is "cannot read properties of undefined (reading permissionOverwrites)", then channel is undefined, not permissionOverwrites
Luxbug
Luxbug•6mo ago
Nah says edit is undefined So permission override is undefined I tried all channel types idk whats the problem
TÆMBØØ
TÆMBØØ•6mo ago
Please share the full error rather than paraphrasing it
Luxbug
Luxbug•6mo ago
Ok…1 sec
Amgelo
Amgelo•6mo ago
and also what Svitkona mentioned, how are you defining channel
Luxbug
Luxbug•6mo 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
Amgelo•6mo ago
well as the error says, private threads don't have a permission overwrites
d.js docs
d.js docs•6mo ago
:method: BaseChannel#isThread @14.15.2 Indicates whether this channel is a ThreadChannel.
TÆMBØØ
TÆMBØØ•6mo ago
Add this typeguard along with your other one to exclude threads
Luxbug
Luxbug•6mo 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