Skip to content

Commit 9d8d8df

Browse files
committed
fix(config): no slash commands was recorded on single server configuration
1 parent 23f5076 commit 9d8d8df

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

rustmail/src/handlers/ready_handler.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use serenity::{
1212
use sqlx::SqlitePool;
1313
use std::sync::Arc;
1414
use std::time::Duration;
15-
use tokio::sync::{watch::Receiver, Mutex};
15+
use tokio::sync::{Mutex, watch::Receiver};
1616
use tokio::time::interval;
1717

1818
#[derive(Clone)]
@@ -78,8 +78,8 @@ impl EventHandler for ReadyHandler {
7878

7979
update_threads_status(&ctx, &pool.clone());
8080

81-
let guild_id = GuildId::new(self.config.bot.get_staff_guild_id());
82-
let guild_id2 = GuildId::new(self.config.bot.get_community_guild_id());
81+
let staff_guild_id = GuildId::new(self.config.bot.get_staff_guild_id());
82+
let community_guild_id = GuildId::new(self.config.bot.get_community_guild_id());
8383

8484
let mut guild_commands: Vec<CreateCommand> = Vec::new();
8585
let mut community_commands: Vec<CreateCommand> = Vec::new();
@@ -94,14 +94,24 @@ impl EventHandler for ReadyHandler {
9494
}
9595
}
9696

97-
if let Err(e) = guild_id
97+
if staff_guild_id == community_guild_id {
98+
if let Err(e) = staff_guild_id.set_commands(&ctx.http, guild_commands).await {
99+
eprintln!("set_commands() failed: {:?}", e);
100+
}
101+
return;
102+
}
103+
104+
if let Err(e) = staff_guild_id
98105
.set_commands(&ctx.http, guild_commands.clone())
99106
.await
100107
{
101108
eprintln!("set_commands() failed: {:?}", e);
102109
}
103110

104-
if let Err(e) = guild_id2.set_commands(&ctx.http, community_commands).await {
111+
if let Err(e) = community_guild_id
112+
.set_commands(&ctx.http, community_commands)
113+
.await
114+
{
105115
eprintln!("set_commands() failed: {:?}", e);
106116
}
107117
}

0 commit comments

Comments
 (0)