SIA
Sapphire - Imagine a framework!" 𝑱𝒂𝒎𝒆𝒔__

! 𝑱𝒂𝒎𝒆𝒔__ - 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
S
Stealth513d ago
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