Skip to content

Commit 3b170f8

Browse files
committed
fix(commands): only register toggle_update_role on the RetroRealm Server
1 parent 094a2ce commit 3b170f8

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/command/mod.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ mod role;
33
mod util;
44

55
use crate::abstraction::command::{CommandData, CommandError};
6-
use crate::command::playmatch::{list, r#match, suggest};
6+
use crate::command::playmatch::{get_game_metadata, list, r#match, suggest};
77
use crate::command::role::toggle_update_role;
88
use crate::command::util::{help, ping};
99
use lazy_static::lazy_static;
1010
use poise::Command;
1111

1212
lazy_static! {
13-
static ref RETROREALM_SERVER_ID: u64 = std::env::var("DISCORD_RETROREALM_SERVER_ID")
13+
pub static ref RETROREALM_SERVER_ID: u64 = std::env::var("DISCORD_RETROREALM_SERVER_ID")
1414
.unwrap_or_default()
1515
.parse()
1616
.unwrap();
@@ -23,13 +23,23 @@ lazy_static! {
2323
.unwrap();
2424
}
2525

26-
pub fn get_commands() -> Vec<Command<CommandData, CommandError>> {
26+
pub fn get_all_commands() -> Vec<Command<CommandData, CommandError>> {
27+
let mut commands = get_global_commands();
28+
commands.extend(retrorealm_server_commands());
29+
commands
30+
}
31+
32+
pub fn get_global_commands() -> Vec<Command<CommandData, CommandError>> {
2733
vec![
2834
help(),
2935
ping(),
30-
toggle_update_role(),
3136
list(),
3237
r#match(),
3338
suggest(),
39+
get_game_metadata(),
3440
]
3541
}
42+
43+
pub fn retrorealm_server_commands() -> Vec<Command<CommandData, CommandError>> {
44+
vec![toggle_update_role()]
45+
}

src/main.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ mod command;
33
mod events;
44
pub mod util;
55

6-
use crate::command::get_commands;
6+
use crate::command::{
7+
RETROREALM_SERVER_ID, get_all_commands, get_global_commands, retrorealm_server_commands,
8+
};
79
use abstraction::command::CommandData;
810
use dotenvy::dotenv;
911
use log::info;
12+
use serenity::all::GuildId;
1013
use serenity::prelude::GatewayIntents;
1114

1215
pub mod built_info {
@@ -34,7 +37,7 @@ async fn main() -> anyhow::Result<()> {
3437

3538
let framework = poise::Framework::builder()
3639
.options(poise::FrameworkOptions {
37-
commands: get_commands(),
40+
commands: get_all_commands(),
3841
post_command: |ctx| {
3942
Box::pin(async move {
4043
let author = ctx.author();
@@ -56,9 +59,17 @@ async fn main() -> anyhow::Result<()> {
5659
},
5760
..Default::default()
5861
})
59-
.setup(|ctx, _ready, framework| {
62+
.setup(|ctx, _ready, _framework| {
6063
Box::pin(async move {
61-
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
64+
poise::builtins::register_globally(ctx, get_global_commands().as_slice()).await?;
65+
66+
poise::builtins::register_in_guild(
67+
ctx,
68+
retrorealm_server_commands().as_slice(),
69+
GuildId::from(*RETROREALM_SERVER_ID),
70+
)
71+
.await?;
72+
6273
Ok(CommandData::default())
6374
})
6475
})

0 commit comments

Comments
 (0)