music commands migrated

This commit is contained in:
2024-02-10 22:22:45 +01:00
parent 6946ddc9f1
commit a27e95a88d
23 changed files with 182 additions and 352 deletions

View File

@@ -1,24 +1,18 @@
use serenity::framework::standard::macros::command;
use serenity::framework::standard::CommandResult;
use serenity::model::prelude::*;
use serenity::prelude::*;
use crate::{Context, Error};
use crate::commands::misc::check_msg;
#[poise::command(prefix_command, slash_command)]
pub async fn mute(ctx: Context<'_>) -> Result<(), Error> {
let guild_id = ctx.guild_id().unwrap();
#[command]
#[only_in(guilds)]
async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
let guild_id = msg.guild_id.unwrap();
let manager = songbird::get(ctx)
let manager = songbird::get(&ctx.serenity_context())
.await
.expect("Client placed at init")
.expect("Songbird client placed at init")
.clone();
let handler_lock = match manager.get(guild_id) {
Some(handler) => handler,
None => {
check_msg(msg.reply(ctx, "Not in a voice channel").await);
ctx.say("Not in a voice channel").await?;
return Ok(());
}
@@ -28,24 +22,16 @@ async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
if handler.is_mute() {
if let Err(e) = handler.mute(false).await {
check_msg(
msg.channel_id
.say(&ctx.http, format!("failed: {:?}", e))
.await,
);
ctx.say(format!("failed: {:?}", e)).await?;
}
check_msg(msg.channel_id.say(&ctx.http, "Unmuted").await);
ctx.say("Unmuted").await?;
} else {
if let Err(err) = handler.mute(true).await {
check_msg(
msg.channel_id
.say(&ctx.http, format!("Failed: {:?}", err))
.await,
);
ctx.say(format!("Failed: {:?}", err)).await?;
}
check_msg(msg.channel_id.say(&ctx.http, "Muted").await);
ctx.say("Muted").await?;
}
Ok(())