! π‘±π’‚π’Žπ’†π’”__ - Hello, I need help with my backup cod...

Hello, I need help with my backup code. The rooms are created correctly but the categories are created with the names of the rooms... Here is a screenshot. Would you please adapt my code because it's been a few days that I'm on it but I can't do it
const backup = backups[id];

backup.channels.forEach(async (channel) => {
console.log(backup)
if (ChannelType.GuildCategory === 4) {
console.log("1")
interaction.guild.channels.create({
name: channel.name,
type: 0,
//nsfw: channel.nsfw,
position: channel.position,
//topic: channel.topic,
reason: channel.reason,
}).then((category) => {
console.log("2")
backup.channels.forEach(async (channel) => {
//category.createChannel({name: channel.name, type: 4, position: channel.position})
if (/*channel.parent === */category.name) {
console.log("oui")

//category.children.create({name: channel.name, type: 4})
interaction.guild.channels.create({ name: channel.name, type: ChannelType.GuildCategory, permissionOverwrites: channel.permissionOverwrites })

/* category.createChannel(channel.name, {
type: 4,
permissionOverwrites: channel.permissionOverwrites,
});*/
}
});
})
}
});
const backup = backups[id];

backup.channels.forEach(async (channel) => {
console.log(backup)
if (ChannelType.GuildCategory === 4) {
console.log("1")
interaction.guild.channels.create({
name: channel.name,
type: 0,
//nsfw: channel.nsfw,
position: channel.position,
//topic: channel.topic,
reason: channel.reason,
}).then((category) => {
console.log("2")
backup.channels.forEach(async (channel) => {
//category.createChannel({name: channel.name, type: 4, position: channel.position})
if (/*channel.parent === */category.name) {
console.log("oui")

//category.children.create({name: channel.name, type: 4})
interaction.guild.channels.create({ name: channel.name, type: ChannelType.GuildCategory, permissionOverwrites: channel.permissionOverwrites })

/* category.createChannel(channel.name, {
type: 4,
permissionOverwrites: channel.permissionOverwrites,
});*/
}
});
})
}
});
No description
1 Reply
⸸⛧Stealth⛧⸸
Your if statement is incorrect, you are comparing ChannelType.GuildCategory === 4, which doesnt make any sense, since you are comparing an enum to a number try doing, channel.type === 4
Want results from more Discord servers?
Add your server