From 4a13bc48325c81a2825a418bee7ed706c777a03f Mon Sep 17 00:00:00 2001 From: Suiranoil Date: Thu, 20 Apr 2023 10:29:31 +0300 Subject: [PATCH 1/3] add meaningful description for creator command --- src/bot/commands/creator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot/commands/creator.rs b/src/bot/commands/creator.rs index 804873e..a749f39 100644 --- a/src/bot/commands/creator.rs +++ b/src/bot/commands/creator.rs @@ -24,7 +24,7 @@ impl MixerCommand for CreatorCommand { fn create(&self, command: &mut CreateApplicationCommand) { command .name(self.name()) - .description("Hello world!") + .description("Some handful commands for the bot's creator!") .create_option(|option| { option .name("verify") From 8f319c50a63c16bc339792829b9a504db9970276 Mon Sep 17 00:00:00 2001 From: Suiranoil Date: Thu, 20 Apr 2023 10:35:42 +0300 Subject: [PATCH 2/3] replace ctx.http with ctx --- src/bot/commands/creator.rs | 4 ++-- src/bot/commands/rating.rs | 2 +- src/bot/handlers/command_handler.rs | 2 +- src/bot/mod.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bot/commands/creator.rs b/src/bot/commands/creator.rs index a749f39..1a457c7 100644 --- a/src/bot/commands/creator.rs +++ b/src/bot/commands/creator.rs @@ -54,7 +54,7 @@ impl MixerCommand for CreatorCommand { if !has_permission { interaction - .create_interaction_response(&ctx.http, |response| { + .create_interaction_response(ctx, |response| { response .kind(InteractionResponseType::ChannelMessageWithSource) .interaction_response_data(|message| { @@ -105,7 +105,7 @@ impl CreatorCommand { } interaction - .create_interaction_response(&ctx.http, |response| { + .create_interaction_response(ctx, |response| { response .kind(InteractionResponseType::ChannelMessageWithSource) .interaction_response_data(|message| { diff --git a/src/bot/commands/rating.rs b/src/bot/commands/rating.rs index d936945..9981041 100644 --- a/src/bot/commands/rating.rs +++ b/src/bot/commands/rating.rs @@ -83,7 +83,7 @@ impl MixerCommand for RatingCommand { User(user, _) => user, _ => { interaction - .create_interaction_response(&ctx.http, |response| { + .create_interaction_response(ctx, |response| { response .kind(InteractionResponseType::ChannelMessageWithSource) .interaction_response_data(|message| { diff --git a/src/bot/handlers/command_handler.rs b/src/bot/handlers/command_handler.rs index f12eec6..61fe5d5 100644 --- a/src/bot/handlers/command_handler.rs +++ b/src/bot/handlers/command_handler.rs @@ -49,7 +49,7 @@ impl MixerCommandHandler { interaction.user.name, interaction.user.id, interaction.data.name ); interaction - .create_interaction_response(&ctx.http, |response| { + .create_interaction_response(ctx, |response| { response .kind(InteractionResponseType::ChannelMessageWithSource) .interaction_response_data(|message| { diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 1f9af32..8b8fd0c 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -123,7 +123,7 @@ impl EventHandler for MixerBot { } Interaction::MessageComponent(component) => { component - .create_interaction_response(ctx.http(), |response| { + .create_interaction_response(ctx, |response| { response.kind(InteractionResponseType::DeferredUpdateMessage) }) .await From 4b8b48ab15159d20fab8551938baad6f0cd64372 Mon Sep 17 00:00:00 2001 From: Suiranoil Date: Thu, 20 Apr 2023 10:41:59 +0300 Subject: [PATCH 3/3] remove new parameter for CommandHandler --- src/bot/handlers/command_handler.rs | 6 ++++-- src/bot/mod.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bot/handlers/command_handler.rs b/src/bot/handlers/command_handler.rs index 61fe5d5..7d78de2 100644 --- a/src/bot/handlers/command_handler.rs +++ b/src/bot/handlers/command_handler.rs @@ -12,8 +12,10 @@ pub struct MixerCommandHandler { } impl MixerCommandHandler { - pub fn new(commands: HashMap>) -> Self { - Self { commands } + pub fn new() -> Self { + Self { + commands: HashMap::new(), + } } pub fn add_command(&mut self, command: T) { diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 8b8fd0c..5b73310 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -25,7 +25,7 @@ pub struct MixerBot { impl MixerBot { pub fn new() -> Self { Self { - command_handler: MixerCommandHandler::new(HashMap::new()), + command_handler: MixerCommandHandler::new(), } }