my bot but a lot of time to move a person !!!

I have set up a temporary channel feature, when a person joins a predefined voice it creates a voice for them and moves them in. I added console.time to see how long it takes
2 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Bouns
BounsOP3y ago
console.time("Create Voice Channel")
let permission = Array.from(newState.channel.parent.permissionOverwrites.cache, ([id, value]) => ({ id, ...value }));

permission.push({
id: newState.member.user.id,
allow: ['ManageChannels', "ViewChannel", "Connect", "Speak", "CreateInstantInvite"],
deny: []
})

//Create new channel if user join channel creator
let channelCreate = await newState.guild.channels.create({
type: ChannelType.GuildVoice,
permissionOverwrites: permission,
userLimit: 6,
name: nameChannelGen.length > 100 ? (nameChannelGen.slice(0, 100)) : (nameChannelGen), type: ChannelType.GuildVoice, parent: newState.channel.parentId
})
console.timeEnd("Create Voice Channel")

console.time("Move to Channel")
await newState.member.voice.setChannel(channelCreate).catch(() => { })
console.timeEnd("Move to Channel")
console.time("Create Voice Channel")
let permission = Array.from(newState.channel.parent.permissionOverwrites.cache, ([id, value]) => ({ id, ...value }));

permission.push({
id: newState.member.user.id,
allow: ['ManageChannels', "ViewChannel", "Connect", "Speak", "CreateInstantInvite"],
deny: []
})

//Create new channel if user join channel creator
let channelCreate = await newState.guild.channels.create({
type: ChannelType.GuildVoice,
permissionOverwrites: permission,
userLimit: 6,
name: nameChannelGen.length > 100 ? (nameChannelGen.slice(0, 100)) : (nameChannelGen), type: ChannelType.GuildVoice, parent: newState.channel.parentId
})
console.timeEnd("Create Voice Channel")

console.time("Move to Channel")
await newState.member.voice.setChannel(channelCreate).catch(() => { })
console.timeEnd("Move to Channel")
this code are in voiceStateUpdate event creation of channel and move is not in rate limit during the action
Want results from more Discord servers?
Add your server