use serenity::all::{CommandInteraction, Context}; use serenity::builder::{CreateCommand, CreateEmbed}; use crate::util::embed::Embed; use crate::util::user_util; pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed { let username = command.user.name.as_str(); let guild_id = match &command.guild_id { Some(guild_id) => guild_id, None => { return Embed::create(username, "GuildId not found", "Could not find guild id."); } }; if !user_util::is_self_connected_to_vc(ctx, guild_id) { // Bot is not connectd to vc; no need to dc return Embed::create( username, "Bot is not connected", "And therefore I cannot stop playing.", ); } let manager = songbird::get(ctx) .await .expect("Cannot get Songbird") .clone(); let has_handler = manager.get(*guild_id).is_some(); if has_handler { if let Err(e) = manager.remove(*guild_id).await { return Embed::create(username, "There was an error", format!("Failed: {:?}", e)); } return Embed::create( username, "I stopped and left\nJust like your girlfriend.", "", ); } Embed::create( username, "Bot is not connected", "And therefore I cannot stop playing.\nSomething happend, which shouldn't have.", ) } pub fn register() -> CreateCommand { CreateCommand::new("stop").description("Stop playing and start leavin'") } // >18/02/2024 @ 19:01:59 - bartlo // >2024-02-19 17:58:39 | moonleay