mirror of
https://github.com/arthur-pbty/shadowbot.git
synced 2026-06-06 14:20:44 +02:00
modify commands categories
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
use serenity::builder::{CreateActionRow, CreateButton, CreateEmbed, CreateMessage};
|
||||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
|
||||
use crate::commands::common::{send_embed, theme_color};
|
||||
|
||||
pub async fn handle_button(ctx: &Context, msg: &Message, args: &[&str]) {
|
||||
if args.len() < 2 {
|
||||
return;
|
||||
}
|
||||
|
||||
let action = args[0].to_lowercase();
|
||||
let link = args[1];
|
||||
|
||||
if action == "add" {
|
||||
let _ = msg
|
||||
.channel_id
|
||||
.send_message(
|
||||
&ctx.http,
|
||||
CreateMessage::new()
|
||||
.content("Bouton personnalisé")
|
||||
.components(vec![CreateActionRow::Buttons(vec![
|
||||
CreateButton::new_link(link).label("Ouvrir"),
|
||||
])]),
|
||||
)
|
||||
.await;
|
||||
} else if action == "del" {
|
||||
send_embed(
|
||||
ctx,
|
||||
msg,
|
||||
CreateEmbed::new()
|
||||
.title("Button")
|
||||
.description("Suppression: supprime simplement le message contenant le bouton.")
|
||||
.color(theme_color(ctx).await),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ButtonCommand;
|
||||
pub static COMMAND_DESCRIPTOR: ButtonCommand = ButtonCommand;
|
||||
|
||||
impl crate::commands::command_contract::CommandSpec for ButtonCommand {
|
||||
fn metadata(&self) -> crate::commands::command_contract::CommandMetadata {
|
||||
crate::commands::command_contract::CommandMetadata {
|
||||
name: "button",
|
||||
category: "outils",
|
||||
params: "<add/del> <lien>",
|
||||
summary: "Gere des boutons decoratifs",
|
||||
description: "Ajoute ou supprime un bouton de decoration personnalise sur un message du bot.",
|
||||
examples: &[
|
||||
"+button add https://example.com",
|
||||
"+button del https://example.com",
|
||||
],
|
||||
default_aliases: &["btn"],
|
||||
default_permission: 8,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user