forked from DiscordBots/Rustendo
fix: fixed not being able to get guild struct, continued work on play command
This commit is contained in:
parent
af50d54729
commit
b2ba381e44
3 changed files with 31 additions and 39 deletions
|
@ -16,7 +16,7 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
|
|||
None
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if query.is_none() {
|
||||
return Embed::create(username, "Error 400", "There is no query provided");
|
||||
}
|
||||
|
@ -37,33 +37,28 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
|
|||
.expect("Cannot get Songbird.")
|
||||
.clone();
|
||||
|
||||
let self_channel = user_util::get_self_vc_id(ctx, &guild_id).await;
|
||||
if !user_util::is_self_connected_to_vc(ctx, &guild_id).await {
|
||||
// self is connected to vc, check if user is in same vc
|
||||
let self_channel = user_util::get_self_vc_id(ctx, &guild_id).await;
|
||||
|
||||
if self_channel.is_err() {
|
||||
return Embed::create(
|
||||
username,
|
||||
"I am not in a VC.",
|
||||
"Connect me to a VC to start playing music.",
|
||||
);
|
||||
if self_channel.is_none() {
|
||||
// Connect to VC
|
||||
manager
|
||||
.join(*guild_id, connect_to)
|
||||
.await
|
||||
.expect("Cannot connect>...");
|
||||
}
|
||||
|
||||
let self_channel = self_channel.unwrap();
|
||||
}
|
||||
let self_channel = self_channel.expect("Cannot get self channel");
|
||||
|
||||
// Check if user is in the same VC as the bot
|
||||
if self_channel != connect_to {
|
||||
return Embed::create(
|
||||
username,
|
||||
"You are not in my VC.",
|
||||
"Connect to my VC to control the music.",
|
||||
);
|
||||
}
|
||||
// Connect to VC
|
||||
manager
|
||||
.join(*guild_id, connect_to)
|
||||
.await
|
||||
.expect("Cannot connect>...");
|
||||
// Check if user is in the same VC as the bot
|
||||
if self_channel != connect_to {
|
||||
return Embed::create(
|
||||
username,
|
||||
"You are not in my VC.",
|
||||
"Connect to my VC to control the music.",
|
||||
);
|
||||
}
|
||||
|
||||
Embed::create(username, "Searching...", format!("Looking for {:?}", query))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue