#channel position

6 messages · Page 1 of 1 (latest)

buoyant mesa
#

i have problem i stored all data channels and permissions in database but when i restore channels its not same position

backup.data.channels.forEach(async (channel) => {
 console.log(channel.name)
setTimeout(async () => {
const parentChannel = channel.parent ? interaction.guild.channels.cache.find(c => c.name === channel.parent && c.type === ChannelType.Category) : null;
const overwrites = channel.permissionOverwrites.map((overwrite) => ({
     id: overwrite.id,
     allow: BigInt(overwrite.allow),
     deny: BigInt(overwrite.deny),
     type: overwrite.type,
   }))
     await interaction.guild.channels.create({ name: channel.name,
       type: channel.type,
       position: channel.position,
       parent: channel.parent,
       permissionOverwrites: overwrites,
     }).catch((err) => {
       console.log(err)
     })
}, 2500)
   })
twilit moth
#

you can't create channels in positions that can't exist, for example if your database has 10 channels saved but your guild is new, you can't set a channel to be at the 10th position because there arent 10 channels

#

what you would probably try to do is either create a guild with your bot and pass the collection or array of channels to it on creation, or use a server template, or create the channels first then sort them as you want (but this might be really spammy)

#

but you can only use the first option if your bot is in less than 10 guilds, your bot will also be the guild owner of that guild

timber spoke
#

it'll have position 10 and if you create a channel of position 9, the new one will be above it