Setting permission overwrite value to null.
Running into an odd issue, simply put:
This ignores setting the connect value to not have a specific override anymore, is there any other way to fix this?
My assumption is that it assumes that if different values are null that they should not be altered, however now the issue is that I do not want to set the value to true or to false but instead to remove that specific permission overwrite on that permission.
Any ideas on how I could achieve this?
5 Replies
- 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 OPDiscord.JS ver. [email protected]
The difference is that I want it to specifically not need to redefine everything else and instead of needing to redefine everything manually for every instance, to be able to just change this one tag or one permission override to be neutral again.
Is there any way to delete the entire override and just copy the entire override and then just leave only the connect as null?
@Qjuh idk if this works but here
const guildId = interaction.guild.id;
const voiceChannel = interaction.guild.channels.cache.find(channel => channel.type === 'GUILD_VOICE' && channel.permissionsFor(guildId).has('CONNECT'));
if (voiceChannel) {
const permissions = voiceChannel.permissionOverwrites.get(guildId) || {
id: guildId,
allow: [],
deny: []
};
// Modify the permissions as needed
permissions.allow.push('CONNECT');
permissions.deny = permissions.deny.filter(permission => permission !== 'CONNECT');
await voiceChannel.permissionOverwrites.edit(guildId, permissions)
.then(() => console.log('Voice channel permissions updated successfully.'))
.catch(error => console.error('Error updating permissions:', error));
} else {
console.error('Voice channel not found.');
}
i just wanted to help 😢Was able to get it working on a newer vers. of DJS, where setting it to Null will make it inbetween true and false.