You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
use serenity::client::Context;
|
|
|
|
use serenity::framework::standard::CommandResult;
|
|
|
|
use serenity::framework::standard::macros::command;
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
|
|
|
|
#[command]
|
|
|
|
#[only_in(guilds)]
|
|
|
|
#[description("Leaves a voice channel")]
|
|
|
|
#[usage("leave")]
|
|
|
|
#[aliases("stop")]
|
|
|
|
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
|
|
|
|
let guild = msg.guild(&ctx.cache).await.unwrap();
|
|
|
|
let guild_id = guild.id;
|
|
|
|
|
|
|
|
let manager = songbird::get(ctx)
|
|
|
|
.await
|
|
|
|
.expect("Songbird Voice client placed in at initialisation.")
|
|
|
|
.clone();
|
|
|
|
|
|
|
|
if manager.get(guild_id).is_some() {
|
|
|
|
manager.remove(guild_id).await?;
|
|
|
|
msg.channel_id.say(ctx, "Left the voice channel").await?;
|
|
|
|
} else {
|
|
|
|
msg.channel_id.say(ctx, "Not in a voice channel").await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|