reformatting

This commit is contained in:
2024-01-30 15:20:39 +01:00
parent a5a9779cb9
commit 0973dbc725
5 changed files with 29 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
use serenity::model::prelude::*;
use serenity::prelude::*;
use serenity::framework::standard::macros::command;
use serenity::framework::standard::CommandResult;
use serenity::model::prelude::*;
use serenity::prelude::*;
use crate::commands::misc::check_msg;
@@ -11,16 +11,16 @@ async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
let guild_id = msg.guild_id.unwrap();
let manager = songbird::get(ctx)
.await
.expect("Client placed at init")
.clone();
.await
.expect("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);
return Ok(())
return Ok(());
}
};
@@ -28,10 +28,13 @@ async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
if handler.is_deaf() {
check_msg(msg.channel_id.say(&ctx.http, "Already deafened").await);
}
else {
} else {
if let Err(err) = handler.deafen(true).await {
check_msg(msg.channel_id.say(&ctx.http, format!("Failed: {:?}", err)).await);
check_msg(
msg.channel_id
.say(&ctx.http, format!("Failed: {:?}", err))
.await,
);
}
check_msg(msg.channel_id.say(&ctx.http, "Deafened").await);

View File

@@ -1,8 +1,8 @@
use serenity::async_trait;
use serenity::model::prelude::*;
use serenity::prelude::*;
use serenity::framework::standard::macros::command;
use serenity::framework::standard::CommandResult;
use serenity::model::prelude::*;
use serenity::prelude::*;
use songbird::events::{Event, EventContext, EventHandler as VoiceEventHandler, TrackEvent};
use crate::commands::misc::check_msg;

View File

@@ -19,12 +19,15 @@ async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
if has_handler {
if let Err(err) = manager.remove(guild_id).await {
check_msg(msg.channel_id.say(&ctx.http, format!("Failed: {:?}", err)).await);
check_msg(
msg.channel_id
.say(&ctx.http, format!("Failed: {:?}", err))
.await,
);
}
check_msg(msg.channel_id.say(&ctx.http, "Left voice channel").await);
}
else {
} else {
check_msg(msg.reply(ctx, "Not in a voice channel").await);
}

View File

@@ -1,3 +1,4 @@
pub mod join;
pub mod deafen;
pub mod join;
pub mod leave;
pub mod mute;

View File

@@ -8,10 +8,7 @@ use serenity::{
async_trait,
client::{Client, EventHandler},
framework::{
standard::{
macros::group,
Configuration,
},
standard::{macros::group, Configuration},
StandardFramework,
},
model::gateway::Ready,
@@ -20,9 +17,10 @@ use serenity::{
mod commands;
use crate::commands::music::join::*;
use crate::commands::music::deafen::*;
use crate::commands::music::join::*;
use crate::commands::music::leave::*;
use crate::commands::music::mute::*;
struct HttpKey;
@@ -40,9 +38,7 @@ impl EventHandler for Handler {
}
#[group]
#[commands(
join, deafen, leave
)]
#[commands(join, deafen, leave, mute)]
struct General;
#[tokio::main]