Files
New-Alan/src/commands/vc.rs

32 lines
794 B
Rust

use serenity::framework::standard::macros::command;
use serenity::framework::standard::CommandResult;
use serenity::model::channel::Message;
use serenity::prelude::Context;
use crate::vc;
#[command]
#[only_in(guilds)]
pub async fn join(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).unwrap();
let channel_id = guild
.voice_states
.get(&msg.author.id)
.and_then(|voice_state| voice_state.channel_id);
msg.channel_id.say(&ctx.http, "pong!").await?;
let connect_to = match channel_id {
Some(channel) => channel,
None => {
msg.reply(ctx, "Not in a voice channel").await;
return Ok(());
},
};
vc::join(ctx.clone(), guild.clone(), connect_to);
Ok(())
}