chore: clippy improvements

This commit is contained in:
Miguel da Mota 2024-03-09 20:09:17 +01:00
parent e1cf394362
commit 9c1f6bee6d
6 changed files with 143 additions and 92 deletions

View file

@ -1,14 +1,15 @@
use crate::music::music_manager;
use serenity::all::{CommandDataOptionValue, CommandInteraction, Context};
use serenity::builder::{CreateCommand, CreateCommandOption, CreateEmbed};
use serenity::model::application::CommandOptionType;
use crate::music::music_manager;
use crate::util::embed::Embed;
pub async unsafe fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
let username = command.user.name.as_str();
let options = &command.data.options;
let query = options.first().and_then(|option| {
if let CommandDataOptionValue::String(query) = &option.value {
Some(query)
@ -16,7 +17,7 @@ pub async unsafe fn run(ctx: &Context, command: &CommandInteraction) -> CreateEm
None
}
});
if query.is_none() {
return Embed::create(username, "Error 400", "There is no query provided");
}
@ -27,8 +28,15 @@ pub async unsafe fn run(ctx: &Context, command: &CommandInteraction) -> CreateEm
return Embed::create(username, "GuildId not found", "Could not find guild id.");
}
};
music_manager::attempt_to_queue_song(&ctx, &guild_id, &command.user.id, &command.user.name, query.unwrap()).await
music_manager::attempt_to_queue_song(
ctx,
guild_id,
&command.user.id,
&command.user.name,
query.unwrap(),
)
.await
}
pub fn register() -> CreateCommand {

View file

@ -1,7 +1,7 @@
use serenity::all::{CommandInteraction, Context};
use serenity::builder::{CreateCommand, CreateEmbed};
use crate::music::music_manager;
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 {
let username = command.user.name.as_str();
@ -13,7 +13,7 @@ pub async unsafe fn run(ctx: &Context, command: &CommandInteraction) -> CreateEm
}
};
music_manager::attempt_to_stop(&ctx, &guild_id, &command.user.id, &command.user.name).await
music_manager::attempt_to_stop(ctx, guild_id, &command.user.id, &command.user.name).await
}
pub fn register() -> CreateCommand {