@@ -6,6 +6,7 @@ use std::{
66
77use anyhow:: Ok ;
88use parking_lot:: Mutex ;
9+ use small_fixed_array:: FixedArray ;
910
1011use poise:: serenity_prelude as serenity;
1112use serenity:: small_fixed_array:: FixedString ;
@@ -56,7 +57,7 @@ async fn main_(start_time: std::time::SystemTime) -> Result<()> {
5657 let http = Arc :: new ( http_builder. build ( ) ) ;
5758
5859 println ! ( "Performing big startup join" ) ;
59- let tts_service = || config. main . tts_services [ 0 ] . clone ( ) ;
60+ let tts_service = || config. tts_services [ 0 ] . url . clone ( ) ;
6061 let (
6162 ws_connections,
6263 webhooks,
@@ -73,7 +74,7 @@ async fn main_(start_time: std::time::SystemTime) -> Result<()> {
7374 shard_count,
7475 premium_user,
7576 ) = tokio:: try_join!(
76- setup_ws_stream( & config. main ) ,
77+ setup_ws_stream( & config. tts_services ) ,
7778 get_webhooks( & http, config. webhooks) ,
7879 create_db_handler!( pool. clone( ) , "guilds" , "guild_id" ) ,
7980 create_db_handler!( pool. clone( ) , "userinfo" , "user_id" ) ,
@@ -111,43 +112,65 @@ async fn main_(start_time: std::time::SystemTime) -> Result<()> {
111112 tokio:: spawn ( analytics. clone ( ) . start ( ) ) ;
112113
113114 let data = Arc :: new ( Data {
114- pool,
115+ analytics,
116+ guilds_db,
117+ userinfo_db,
118+ nickname_db,
119+ user_voice_db,
120+ guild_voice_db,
121+
122+ entitlement_cache : mini_moka:: sync:: Cache :: builder ( )
123+ . time_to_live ( Duration :: from_hours ( 1 ) )
124+ . build ( ) ,
125+ startup_message,
126+ premium_avatar_url : FixedString :: from_string_trunc ( premium_user. face ( ) ) ,
115127 system_info : Mutex :: new ( sysinfo:: System :: new ( ) ) ,
116- bot_list_tokens : Mutex :: new ( config. bot_list_tokens ) ,
128+ start_time,
129+ reqwest,
130+ regex_cache : RegexCache :: new ( ) ?,
131+ webhooks,
132+ pool,
117133
134+ service_weight_lookups : FixedArray :: try_from (
135+ config
136+ . tts_services
137+ . iter ( )
138+ . enumerate ( )
139+ . flat_map ( |( index, service) | {
140+ ( 1 ..=service. weight . get ( ) ) . map ( move |_| index. try_into ( ) . unwrap ( ) )
141+ } )
142+ . collect :: < Box < [ _ ] > > ( ) ,
143+ )
144+ . unwrap ( ) ,
145+ tts_services : FixedArray :: try_from (
146+ config
147+ . tts_services
148+ . into_iter ( )
149+ . map ( |service| service. url )
150+ . collect :: < Box < [ _ ] > > ( ) ,
151+ )
152+ . unwrap ( ) ,
118153 ws_connections,
154+ voice_connections : Mutex :: default ( ) ,
155+
156+ config : config. main ,
157+ premium_config : config. premium ,
119158 runners : OnceLock :: new ( ) , // Filled in later
159+
160+ website_info : Mutex :: new ( config. website_info ) ,
161+ bot_list_tokens : Mutex :: new ( config. bot_list_tokens ) ,
120162 fully_started : AtomicBool :: new ( false ) ,
121- voice_connections : parking_lot:: Mutex :: default ( ) ,
122163 update_startup_lock : tokio:: sync:: Mutex :: new ( ( ) ) ,
123- entitlement_cache : mini_moka:: sync:: Cache :: builder ( )
124- . time_to_live ( Duration :: from_hours ( 1 ) )
125- . build ( ) ,
126164
127- gtts_voices,
128165 espeak_voices,
129- translation_languages,
130- gcloud_voices : prepare_gcloud_voices ( gcloud_voices) ,
166+ gtts_voices,
131167 polly_voices : polly_voices
132168 . into_iter ( )
133169 . map ( |v| ( v. id . clone ( ) , v) )
134170 . collect :: < BTreeMap < _ , _ > > ( ) ,
171+ gcloud_voices : prepare_gcloud_voices ( gcloud_voices) ,
135172
136- config : config. main ,
137- premium_config : config. premium ,
138- website_info : Mutex :: new ( config. website_info ) ,
139- reqwest,
140- premium_avatar_url : FixedString :: from_string_trunc ( premium_user. face ( ) ) ,
141- analytics,
142- webhooks,
143- start_time,
144- startup_message,
145- regex_cache : RegexCache :: new ( ) ?,
146- guilds_db,
147- userinfo_db,
148- nickname_db,
149- user_voice_db,
150- guild_voice_db,
173+ translation_languages,
151174 } ) ;
152175
153176 let framework_options = poise:: FrameworkOptions {
0 commit comments