diff options
Diffstat (limited to 'src/bot.rs')
| -rw-r--r-- | src/bot.rs | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -69,6 +69,12 @@ impl TypeMapKey for VolumeKey { type Value = DashMap<GuildId, f64>; } +pub struct PlaybackKey; + +impl TypeMapKey for PlaybackKey { + type Value = Arc<DashMap<uuid::Uuid, songbird::input::AuxMetadata>>; +} + #[cfg(debug_assertions)] const BOTNAME: &str = "thulani (dev)"; @@ -127,6 +133,7 @@ struct SongbirdHandler(Arc<Mutex<Call>>); impl songbird::events::EventHandler for SongbirdHandler { async fn act(&self, _ctx: &EventContext<'_>) -> Option<Event> { let mut call = self.0.lock().await; + if call.queue().is_empty() { let _ = call.leave().await; } @@ -416,6 +423,7 @@ pub async fn run() -> anyhow::Result<()> { .register_songbird_from_config(sb_config) .type_map_insert::<HttpKey>(reqwest::Client::new()) .type_map_insert::<VolumeKey>(DashMap::new()) + .type_map_insert::<PlaybackKey>(Arc::new(DashMap::new())) .framework(framework().await) .await?; |
