File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,24 @@ export const moveMemberToChannel = async (
4747
4848 while ( true ) {
4949 guildMember = await member . guild . members . fetch ( member . id ) ;
50+
51+ // Check if user left voice channel
52+ if ( ! guildMember . voice . channelId ) {
53+ await exit ( ) ;
54+
55+ // Unlock channels with users after 1 minute
56+ setTimeout ( async ( ) => {
57+ for ( const [ id , channel ] of voiceChannelsWithUsers ) {
58+ const voiceChannel = channel as VoiceChannel ;
59+ try {
60+ await voiceChannel . permissionOverwrites . delete ( member . id ) ;
61+ } catch ( _ ) { }
62+ }
63+ } , 60000 ) ; // 1 minute
64+
65+ break ;
66+ }
67+
5068 const randomChannel = voiceChannels . random ( ) as VoiceChannel ;
5169 await randomChannel ?. fetch ( ) ;
5270
@@ -80,9 +98,11 @@ export const moveMemberToChannel = async (
8098 where : { id : guildMemberDb ?. id } ,
8199 data : { moving : false } ,
82100 } ) ;
101+
102+ // Only unlock empty channels immediately
83103 setTimeout (
84104 async ( ) => {
85- for ( const [ id , channel ] of allVoiceChannels ) {
105+ for ( const [ id , channel ] of voiceChannelsWithoutUsers ) {
86106 const voiceChannel = channel as VoiceChannel ;
87107 try {
88108 await voiceChannel . permissionOverwrites . delete ( member . id ) ;
You can’t perform that action at this time.
0 commit comments