mirror of
https://github.com/eRgo35/lyra.git
synced 2026-02-04 12:26:10 +01:00
0.5.1 refractor
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
use crate::{commands::embeds::{error_embed, embed, fail}, Context, Error};
|
||||
use crate::{
|
||||
commands::embeds::{embed, error_embed, fail},
|
||||
Context, Error,
|
||||
};
|
||||
use poise::CreateReply;
|
||||
|
||||
/// Mutes itself while in a voice channel; \
|
||||
/// aliases: mute, unmute, shhh
|
||||
#[poise::command(
|
||||
prefix_command,
|
||||
prefix_command,
|
||||
slash_command,
|
||||
aliases("shhh", "unmute"),
|
||||
category = "Music"
|
||||
)]
|
||||
pub async fn mute(
|
||||
ctx: Context<'_>
|
||||
) -> Result<(), Error> {
|
||||
pub async fn mute(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let guild_id = ctx.guild_id().unwrap();
|
||||
|
||||
let manager = songbird::get(&ctx.serenity_context())
|
||||
@@ -21,33 +22,30 @@ pub async fn mute(
|
||||
|
||||
let handler_lock = match manager.get(guild_id) {
|
||||
Some(handler) => handler,
|
||||
None => {
|
||||
None => {
|
||||
let msg = "I am not in a voice channel!";
|
||||
ctx.send(
|
||||
CreateReply::default().embed(error_embed(ctx, msg).await.unwrap())
|
||||
).await?;
|
||||
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let mut handler = handler_lock.lock().await;
|
||||
|
||||
if handler.is_mute() {
|
||||
if handler.is_mute() {
|
||||
if let Err(err) = handler.mute(false).await {
|
||||
fail(ctx, err.to_string()).await.unwrap();
|
||||
}
|
||||
|
||||
ctx.send(
|
||||
CreateReply::default().embed(embed(ctx, "Unmuted!", "", "").await.unwrap())
|
||||
).await?;
|
||||
|
||||
ctx.send(CreateReply::default().embed(embed(ctx, "Unmuted!", "", "").await.unwrap()))
|
||||
.await?;
|
||||
} else {
|
||||
if let Err(err) = handler.mute(true).await {
|
||||
fail(ctx, err.to_string()).await.unwrap();
|
||||
}
|
||||
|
||||
ctx.send(
|
||||
CreateReply::default().embed(embed(ctx, "Muted!", "", "").await.unwrap())
|
||||
).await?;
|
||||
|
||||
ctx.send(CreateReply::default().embed(embed(ctx, "Muted!", "", "").await.unwrap()))
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user