Debug join command
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
use serenity::framework::standard::macros::group;
|
use serenity::framework::standard::macros::group;
|
||||||
|
|
||||||
pub mod ping;
|
pub mod ping;
|
||||||
use ping::*;
|
use ping::*;
|
||||||
|
|
||||||
|
pub mod vc;
|
||||||
|
use vc::*;
|
||||||
|
|
||||||
#[group]
|
#[group]
|
||||||
#[commands(ping)]
|
#[commands(ping, join)]
|
||||||
pub struct General;
|
pub struct General;
|
||||||
|
|||||||
31
src/commands/vc.rs
Normal file
31
src/commands/vc.rs
Normal 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(())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user