Debug join command

This commit is contained in:
2023-03-12 13:20:01 -04:00
parent 7797dbf89a
commit 57457a0724
2 changed files with 36 additions and 1 deletions

View File

@@ -1,7 +1,11 @@
use serenity::framework::standard::macros::group;
pub mod ping;
use ping::*;
pub mod vc;
use vc::*;
#[group]
#[commands(ping)]
#[commands(ping, join)]
pub struct General;

31
src/commands/vc.rs Normal file
View File

@@ -0,0 +1,31 @@
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(())
}