Fix potential issue where bot doesn't leave automatically
This commit is contained in:
		
							parent
							
								
									854724b389
								
							
						
					
					
						commit
						78962772e7
					
				
							
								
								
									
										11
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.rs
									
									
									
									
									
								
							| @ -112,6 +112,7 @@ async fn main() { | |||||||
|         _ = tokio::time::sleep(std::time::Duration::from_secs(60)) => { |         _ = tokio::time::sleep(std::time::Duration::from_secs(60)) => { | ||||||
|           let guild_count = cache.guilds().len(); |           let guild_count = cache.guilds().len(); | ||||||
|           let active_count = session_manager.get_active_session_count().await; |           let active_count = session_manager.get_active_session_count().await; | ||||||
|  |           let total_count = session_manager.get_session_count().await; | ||||||
| 
 | 
 | ||||||
|           if let Err(why) = stats_manager.set_server_count(guild_count) { |           if let Err(why) = stats_manager.set_server_count(guild_count) { | ||||||
|             error!("Failed to update server count: {}", why); |             error!("Failed to update server count: {}", why); | ||||||
| @ -122,7 +123,15 @@ async fn main() { | |||||||
|           } |           } | ||||||
| 
 | 
 | ||||||
|           // Yes, I like to handle my s's when I'm working with amounts
 |           // Yes, I like to handle my s's when I'm working with amounts
 | ||||||
|           debug!("Updated stats: {} guild{}, {} active session{}", guild_count, if guild_count == 1 { "" } else { "s" }, active_count, if active_count == 1 { "" } else { "s" }); |           debug!( | ||||||
|  |             "Updated stats: {} guild{}, {} active session{}, {} total session{}", | ||||||
|  |             guild_count, | ||||||
|  |             if guild_count == 1 { "" } else { "s" }, | ||||||
|  |             active_count, | ||||||
|  |             if active_count == 1 { "" } else { "s" }, | ||||||
|  |             total_count, | ||||||
|  |             if total_count == 1 { "" } else { "s" } | ||||||
|  |           ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         _ = tokio::signal::ctrl_c() => { |         _ = tokio::signal::ctrl_c() => { | ||||||
|  | |||||||
| @ -108,6 +108,13 @@ impl SessionManager { | |||||||
|     sessions.get(&guild_id).cloned() |     sessions.get(&guild_id).cloned() | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   /// Get the amount of sessions
 | ||||||
|  |   pub async fn get_session_count(&self) -> usize { | ||||||
|  |     let sessions = self.sessions.read().await; | ||||||
|  | 
 | ||||||
|  |     sessions.len() | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   /// Get the amount of sessions with an owner
 |   /// Get the amount of sessions with an owner
 | ||||||
|   pub async fn get_active_session_count(&self) -> usize { |   pub async fn get_active_session_count(&self) -> usize { | ||||||
|     let sessions = self.sessions.read().await; |     let sessions = self.sessions.read().await; | ||||||
|  | |||||||
| @ -306,6 +306,8 @@ impl SpoticordSession { | |||||||
| 
 | 
 | ||||||
|           IpcPacket::Stopped => { |           IpcPacket::Stopped => { | ||||||
|             check_result(ipc_track.pause()); |             check_result(ipc_track.pause()); | ||||||
|  | 
 | ||||||
|  |             ipc_instance.playback_info.write().await.take(); | ||||||
|             ipc_instance.start_disconnect_timer().await; |             ipc_instance.start_disconnect_timer().await; | ||||||
|           } |           } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 DaXcess
						DaXcess