mirror of
https://github.com/arthur-pbty/shadowbot.git
synced 2026-06-03 15:07:37 +02:00
72 lines
2.5 KiB
Rust
72 lines
2.5 KiB
Rust
use serenity::builder::CreateEmbed;
|
|
use serenity::model::prelude::*;
|
|
use serenity::prelude::*;
|
|
|
|
use crate::commands::common::{send_embed, theme_color};
|
|
use crate::commands::logs_command_helpers::{parse_target_channel, set_log_channel};
|
|
|
|
pub async fn handle_voicelog(ctx: &Context, msg: &Message, args: &[&str]) {
|
|
let Some(guild_id) = msg.guild_id else {
|
|
return;
|
|
};
|
|
|
|
let Some(action) = args.first().map(|s| s.to_lowercase()) else {
|
|
let embed = CreateEmbed::new()
|
|
.title("VoiceLog")
|
|
.description("Usage: +voicelog <on [salon]|off>")
|
|
.color(0xED4245);
|
|
send_embed(ctx, msg, embed).await;
|
|
return;
|
|
};
|
|
|
|
match action.as_str() {
|
|
"on" => {
|
|
let channel = parse_target_channel(msg, args, 1);
|
|
set_log_channel(ctx, guild_id, "voice", channel, true).await;
|
|
let embed = CreateEmbed::new()
|
|
.title("VoiceLog")
|
|
.description(format!(
|
|
"Active dans {}.",
|
|
channel
|
|
.map(|c| format!("<#{}>", c.get()))
|
|
.unwrap_or_else(|| "ce salon".to_string())
|
|
))
|
|
.color(theme_color(ctx).await);
|
|
send_embed(ctx, msg, embed).await;
|
|
}
|
|
"off" => {
|
|
set_log_channel(ctx, guild_id, "voice", None, false).await;
|
|
let embed = CreateEmbed::new()
|
|
.title("VoiceLog")
|
|
.description("Desactive.")
|
|
.color(theme_color(ctx).await);
|
|
send_embed(ctx, msg, embed).await;
|
|
}
|
|
_ => {
|
|
let embed = CreateEmbed::new()
|
|
.title("VoiceLog")
|
|
.description("Usage: +voicelog <on [salon]|off>")
|
|
.color(0xED4245);
|
|
send_embed(ctx, msg, embed).await;
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct VoicelogCommand;
|
|
pub static COMMAND_DESCRIPTOR: VoicelogCommand = VoicelogCommand;
|
|
|
|
impl crate::commands::command_contract::CommandSpec for VoicelogCommand {
|
|
fn metadata(&self) -> crate::commands::command_contract::CommandMetadata {
|
|
crate::commands::command_contract::CommandMetadata {
|
|
name: "voicelog",
|
|
category: "logs",
|
|
params: "<on [salon]|off>",
|
|
summary: "Active les logs vocaux",
|
|
description: "Active ou desactive les logs de l activite vocale.",
|
|
examples: &["+voicelog on #logs", "+voicelog off"],
|
|
default_aliases: &["vlog"],
|
|
default_permission: 8,
|
|
}
|
|
}
|
|
}
|