diff --git a/src/commands/info.rs b/src/commands/info.rs index 2c93d36..a708372 100644 --- a/src/commands/info.rs +++ b/src/commands/info.rs @@ -3,9 +3,7 @@ use serenity::builder::{CreateCommand, CreateEmbed}; use crate::util::embed::Embed; -pub async fn run(_ctx: &Context, command: &CommandInteraction) -> CreateEmbed { - let username = command.user.name.as_str(); - +pub async fn run(_ctx: &Context, _command: &CommandInteraction) -> CreateEmbed { Embed::create( "", "Botendo v7", diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 6eaf7b9..755a0ee 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,3 +1,3 @@ pub mod info; pub mod play; -pub mod stop; \ No newline at end of file +pub mod stop; diff --git a/src/commands/play.rs b/src/commands/play.rs index 8613fd2..1e05661 100644 --- a/src/commands/play.rs +++ b/src/commands/play.rs @@ -6,7 +6,7 @@ use serenity::model::application::CommandOptionType; use crate::util::embed::Embed; -pub async unsafe fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed { +pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed { let username = command.user.name.as_str(); let options = &command.data.options; diff --git a/src/commands/stop.rs b/src/commands/stop.rs index 8a65e35..665a24d 100644 --- a/src/commands/stop.rs +++ b/src/commands/stop.rs @@ -3,7 +3,7 @@ use crate::util::embed::Embed; use serenity::all::{CommandInteraction, Context}; use serenity::builder::{CreateCommand, CreateEmbed}; -pub async unsafe fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed { +pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed { let username = command.user.name.as_str(); let guild_id = match &command.guild_id { diff --git a/src/main.rs b/src/main.rs index 55eeaf4..20611a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,22 +63,20 @@ struct Handler; #[async_trait] impl EventHandler for Handler { async fn interaction_create(&self, ctx: Context, interaction: Interaction) { - unsafe { - if let Interaction::Command(command) = interaction { - let _ = &command.defer(&ctx.http()).await.expect("Cannot defer"); + if let Interaction::Command(command) = interaction { + let _ = &command.defer(&ctx.http()).await.expect("Cannot defer"); - let content = Some(match command.data.name.as_str() { - "info" => commands::info::run(&ctx, &command).await, - "play" => commands::play::run(&ctx, &command).await, - "stop" => commands::stop::run(&ctx, &command).await, - _ => respond_with_error(&ctx, &command).await, - }); + let content = Some(match command.data.name.as_str() { + "info" => commands::info::run(&ctx, &command).await, + "play" => commands::play::run(&ctx, &command).await, + "stop" => commands::stop::run(&ctx, &command).await, + _ => respond_with_error(&ctx, &command).await, + }); - if let Some(embed) = content { - let followup = CreateInteractionResponseFollowup::new().embed(embed); - if let Err(why) = command.create_followup(&ctx.http, followup).await { - println!("Cannot followup to slash command: {why}") - } + if let Some(embed) = content { + let followup = CreateInteractionResponseFollowup::new().embed(embed); + if let Err(why) = command.create_followup(&ctx.http, followup).await { + println!("Cannot followup to slash command: {why}") } } } diff --git a/src/music/music_manager.rs b/src/music/music_manager.rs index 2f42673..e1e9f13 100644 --- a/src/music/music_manager.rs +++ b/src/music/music_manager.rs @@ -224,9 +224,7 @@ pub async fn stop(ctx: &Context, guild_id: &GuildId) -> Result .expect("Cannot get Songbird") .clone(); - let has_handler = manager.get(*guild_id).is_some(); - - if has_handler { + if manager.get(*guild_id).is_some() { manager.remove(*guild_id).await?; return Ok(true); // Handler removed } diff --git a/src/util/user_util.rs b/src/util/user_util.rs index 32c5423..c3ef10a 100644 --- a/src/util/user_util.rs +++ b/src/util/user_util.rs @@ -12,6 +12,7 @@ pub fn request_guild(ctx: &Context, guild_id: &GuildId) -> Guild { } /// Request a guild by id, get it from Discord, not from cache, this is a partial guild +#[allow(dead_code)] pub async fn request_partial_guild(ctx: &Context, guild_id: &GuildId) -> PartialGuild { match ctx.http.get_guild(*guild_id).await { Ok(guild) => guild, @@ -32,16 +33,12 @@ pub async fn get_vc_id(ctx: &Context, guild_id: &GuildId, user_id: &UserId) -> O /// Check if the bot is connected to a voice channel pub async fn is_self_connected_to_vc(ctx: &Context, guild_id: &GuildId) -> bool { - let channel_id = get_self_vc_id(ctx, guild_id); - - channel_id.await.is_some() + get_self_vc_id(ctx, guild_id).await.is_some() } /// Check if a user is connected to a voice channel pub async fn is_user_connected_to_vc(ctx: &Context, guild_id: &GuildId, user_id: &UserId) -> bool { - let channel_id = get_vc_id(ctx, guild_id, user_id).await; - - channel_id.is_some() + get_vc_id(ctx, guild_id, user_id).await.is_some() } /// Get the voice channel id of the bot