fix: fixed import errors

feat: removed unneeded functions, added logging to user_util
This commit is contained in:
moonleay 2024-03-04 23:39:36 +01:00
parent 57e9bca8f0
commit 4d6e665a3b
Signed by: moonleay
GPG key ID: 82667543CCD715FB
3 changed files with 43 additions and 56 deletions

View file

@ -1,9 +1,9 @@
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, Context};
use serenity::all::{CommandDataOptionValue, CommandInteraction, Context};
use serenity::builder::{CreateCommand, CreateCommandOption, CreateEmbed};
use serenity::model::application::CommandOptionType;
use crate::util::embed::Embed;
use crate::util::user_util::{self, get_guild};
use crate::util::user_util::{self, get_vc_id};
pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
let username = command.user.name.as_str();
@ -27,35 +27,10 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
return Embed::create(username, "GuildId not found", "Could not find guild id.");
}
};
println!("Guild ID: {:?}", guild_id);
let (guild_id, channel_id) = {
let guild = get_guild(ctx, guild_id);
match guild {
Some(guild) => {
let channel_id = guild
.voice_states
.get(&command.user.id)
.and_then(|voice_state| voice_state.channel_id);
(guild.id, channel_id)
}
None => {
return Embed::create(username, "Guild not found", "Could not find guild.");
}
}
};
let connect_to = match channel_id {
Some(channel) => channel,
None => {
return Embed::create(
username,
"You are not in a VC.",
"Join one to start playing music.",
);
}
};
let connect_to = get_vc_id(ctx, &guild_id, &command.user.id).expect("Cannot get channel id");
let manager = &songbird::get(ctx)
.await
@ -86,12 +61,12 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
}
// Connect to VC
manager
.join(guild_id, connect_to)
.join(*guild_id, connect_to)
.await
.expect("Cannot connect>...");
}
Embed::create(username, "Searching...", format!("Looking for {}", query))
Embed::create(username, "Searching...", format!("Looking for {:?}", query))
}
pub fn register() -> CreateCommand {