Giving a member permission to change permissions in a selected channel

What is supposed to happen: User gets permission to change permissions in a selected voice channel What happens: User does not have permission to change permissions in selected voice channel code:
async function addTempChannel(member, guild) {

var channel = await guild.channels.create({
name: member.displayName,
type: ChannelType.GuildVoice,
parent: await JSON.parse(fs.readFileSync("./channels.json", { encoding: "utf8" }))[guild.id].categoryChannel,
permissionOverwrites: [
{
id: member.user.id,
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.Connect, PermissionsBitField.Flags.ManageChannels, PermissionsBitField.Flags.Administrator]
},
{
id: guild.roles.everyone,
deny: [PermissionsBitField.Flags.Connect]
}
]
});

var removed = false;

await moveMember(member, channel).catch(() => {
removeTempChannel(channel);
removed = true;
});

if(channel.members.size < 1) {
console.log("removing");
removeTempChannel(channel);
removed = true;
}

if(removed) return;

const data = await JSON.parse(fs.readFileSync("./temp_channels.json", { encoding: "utf8" }));

data.push(channel.id);

fs.writeFileSync("./temp_channels.json", JSON.stringify(data));

}
async function addTempChannel(member, guild) {

var channel = await guild.channels.create({
name: member.displayName,
type: ChannelType.GuildVoice,
parent: await JSON.parse(fs.readFileSync("./channels.json", { encoding: "utf8" }))[guild.id].categoryChannel,
permissionOverwrites: [
{
id: member.user.id,
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.Connect, PermissionsBitField.Flags.ManageChannels, PermissionsBitField.Flags.Administrator]
},
{
id: guild.roles.everyone,
deny: [PermissionsBitField.Flags.Connect]
}
]
});

var removed = false;

await moveMember(member, channel).catch(() => {
removeTempChannel(channel);
removed = true;
});

if(channel.members.size < 1) {
console.log("removing");
removeTempChannel(channel);
removed = true;
}

if(removed) return;

const data = await JSON.parse(fs.readFileSync("./temp_channels.json", { encoding: "utf8" }));

data.push(channel.id);

fs.writeFileSync("./temp_channels.json", JSON.stringify(data));

}
moveMember method incase needed:
async function moveMember(member, voicechannel) {

return await member.voice.setChannel(voicechannel);

}
async function moveMember(member, voicechannel) {

return await member.voice.setChannel(voicechannel);

}
removeTempChannel method incase needed:
async function removeTempChannel(channel) {

if(isNullOrUndefined(channel) || isNullOrUndefined(channel.name)) {
console.log("fail");
return;
}

if(isNullOrUndefined(deleter.get(channel.guild))) deleter.set(channel.guild, new Deleter());

await deleter.get(channel.guild).add(channel);

}
async function removeTempChannel(channel) {

if(isNullOrUndefined(channel) || isNullOrUndefined(channel.name)) {
console.log("fail");
return;
}

if(isNullOrUndefined(deleter.get(channel.guild))) deleter.set(channel.guild, new Deleter());

await deleter.get(channel.guild).add(channel);

}
2 Replies
d.js toolkit
d.js toolkit16mo 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!
Steep
SteepOP16mo ago
discord.js = v14.12.1 node = v18.17.1 also there is no errors solved by people in #djs-help-v14
Want results from more Discord servers?
Add your server