@@ -11,6 +11,7 @@ use serenity::prelude::TypeMapKey;
1111use std:: collections:: HashMap ;
1212use std:: process;
1313use std:: sync:: Arc ;
14+ use std:: sync:: atomic:: AtomicBool ;
1415use std:: time:: Duration ;
1516use tokio:: sync:: Mutex ;
1617use tokio:: { select, spawn} ;
@@ -36,6 +37,7 @@ pub async fn init_bot_state() -> Arc<Mutex<BotState>> {
3637 command_tx : command_tx. clone ( ) ,
3738 bot_http : None ,
3839 bot_context : Arc :: new ( tokio:: sync:: RwLock :: new ( None ) ) ,
40+ maintenance_mode : Arc :: new ( AtomicBool :: new ( false ) ) ,
3941 } ;
4042
4143 Arc :: new ( Mutex :: new ( bot_state) )
@@ -90,12 +92,15 @@ pub async fn run_bot(
9092 state_lock. db_pool . clone ( ) . expect ( "Database pool not set" )
9193 } ;
9294
93- let mut config = {
95+ let ( mut config, maintenance_mode ) = {
9496 let state_lock = bot_state. lock ( ) . await ;
9597 if state_lock. config . is_none ( ) {
9698 panic ! ( "Config not set before starting rustmail!" ) ;
9799 }
98- state_lock. config . clone ( ) . expect ( "Config not set" )
100+ (
101+ state_lock. config . clone ( ) . expect ( "Config not set" ) ,
102+ state_lock. maintenance_mode . clone ( ) ,
103+ )
99104 } ;
100105
101106 let pagination = Arc :: new ( Mutex :: new ( HashMap :: < String , PaginationContext > :: new ( ) ) ) ;
@@ -139,6 +144,7 @@ pub async fn run_bot(
139144 registry. register_command ( ReleaseCommand ) ;
140145 registry. register_command ( PingCommand ) ;
141146 registry. register_command ( SnippetCommand ) ;
147+ registry. register_command ( StatusCommand ) ;
142148
143149 let registry = Arc :: new ( registry) ;
144150
@@ -156,6 +162,7 @@ pub async fn run_bot(
156162 registry. clone ( ) ,
157163 shutdown_rx. clone ( ) ,
158164 pagination. clone ( ) ,
165+ maintenance_mode. clone ( ) ,
159166 )
160167 . await ,
161168 )
@@ -168,6 +175,7 @@ pub async fn run_bot(
168175 registry. clone ( ) ,
169176 shutdown_rx,
170177 pagination,
178+ maintenance_mode,
171179 ) )
172180 . event_handler ( GuildHandler :: new ( & config) )
173181 . await
0 commit comments