0.5.0 embed, help, refractor

This commit is contained in:
2024-02-13 18:44:01 +01:00
parent d75c5bc9a2
commit 8fa86b0182
24 changed files with 341 additions and 94 deletions

View File

@@ -1,16 +1,29 @@
use crate::{Context, Error};
use crate::{commands::embeds::{error_embed, embed}, Context, Error};
use poise::CreateReply;
use songbird::TrackEvent;
use crate::commands::music::misc::TrackErrorNotifier;
use crate::commands::music::notifier::TrackErrorNotifier;
#[poise::command(prefix_command, slash_command)]
pub async fn join(ctx: Context<'_>) -> Result<(), Error> {
/// Joins your voice channel
#[poise::command(
prefix_command,
slash_command,
category = "Music"
)]
pub async fn join(
ctx: Context<'_>
) -> Result<(), Error> {
let guild_id = ctx.guild_id().unwrap();
let channel_id = ctx.guild().unwrap().voice_states.get(&ctx.author().id).and_then(|voice_state| voice_state.channel_id);
let channel_id = ctx.guild().unwrap()
.voice_states.get(&ctx.author().id)
.and_then(|voice_state| voice_state.channel_id);
let connect_to = match channel_id {
Some(channel) => channel,
None => {
ctx.say("Not in a voice channel").await?;
let msg = "I am not in a voice channel!";
ctx.send(
CreateReply::default().embed(error_embed(ctx, msg).await.unwrap())
).await?;
return Ok(());
}
};
@@ -25,7 +38,9 @@ pub async fn join(ctx: Context<'_>) -> Result<(), Error> {
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
}
ctx.say("Joined the voice channel").await?;
ctx.send(
CreateReply::default().embed(embed(ctx, "Joined!", "Hi there!", "").await.unwrap())
).await?;
Ok(())
}