aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index df40481..4e308b8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,6 +13,7 @@ mod database;
13mod error; 13mod error;
14mod events; 14mod events;
15mod lang; 15mod lang;
16mod music;
16mod openrouter; 17mod openrouter;
17mod recording; 18mod recording;
18mod tasks; 19mod tasks;
@@ -49,8 +50,8 @@ pub struct Data {
49 /// Populated by background tasks when the first search times out, so the 50 /// Populated by background tasks when the first search times out, so the
50 /// next keystroke's autocomplete can serve real results immediately. 51 /// next keystroke's autocomplete can serve real results immediately.
51 pub ac_search_cache: AcSearchCache, 52 pub ac_search_cache: AcSearchCache,
52 /// Active music track per guild (only one music source at a time). 53 /// Active music queue and current track per guild.
53 pub music_tracks: Arc<tokio::sync::Mutex<HashMap<u64, songbird::tracks::TrackHandle>>>, 54 pub music: Arc<music::MusicState>,
54 /// TTS engine: piper model + audio cache. 55 /// TTS engine: piper model + audio cache.
55 pub tts: Arc<tts::TtsState>, 56 pub tts: Arc<tts::TtsState>,
56} 57}
@@ -198,7 +199,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
198 ) 199 )
199 .await?; 200 .await?;
200 201
201 let music_tracks: Arc<tokio::sync::Mutex<HashMap<u64, songbird::tracks::TrackHandle>>> = Arc::new(tokio::sync::Mutex::new(HashMap::new())); 202 let music = music::MusicState::new(
203 vm.clone(),
204 ctx.http.clone(),
205 http_client.clone(),
206 );
202 207
203 let tts = Arc::new(tts::TtsState::new(config.piper_model_path())); 208 let tts = Arc::new(tts::TtsState::new(config.piper_model_path()));
204 209
@@ -213,7 +218,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
213 triggers: tokio::sync::Mutex::new(triggers), 218 triggers: tokio::sync::Mutex::new(triggers),
214 ac_cache: tokio::sync::Mutex::new(HashMap::new()), 219 ac_cache: tokio::sync::Mutex::new(HashMap::new()),
215 ac_search_cache: Arc::new(tokio::sync::Mutex::new(HashMap::new())), 220 ac_search_cache: Arc::new(tokio::sync::Mutex::new(HashMap::new())),
216 music_tracks: music_tracks.clone(), 221 music,
217 }; 222 };
218 223
219 // Spawn cron scheduler loop. 224 // Spawn cron scheduler loop.
@@ -221,9 +226,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
221 let cron_ctx = crate::tasks::CronContext { 226 let cron_ctx = crate::tasks::CronContext {
222 pool: data.db_pool.clone(), 227 pool: data.db_pool.clone(),
223 http: ctx.http.clone(), 228 http: ctx.http.clone(),
224 voice_manager: data.voice_manager.clone(),
225 copyparty: data.copyparty.clone(), 229 copyparty: data.copyparty.clone(),
226 music_tracks: music_tracks.clone(), 230 music: data.music.clone(),
227 }; 231 };
228 tokio::spawn(async move { 232 tokio::spawn(async move {
229 crate::tasks::cron_scheduler_loop(cron_ctx).await; 233 crate::tasks::cron_scheduler_loop(cron_ctx).await;