feat: make the admin hable to init the config
This commit is contained in:
parent
12ae78d934
commit
dd67020b3e
@ -1,8 +1,5 @@
|
||||
use crate::botv2::{
|
||||
domain::server_config::{
|
||||
change_enable_server::change_enable_server,
|
||||
check_if_server_enable_and_admin::check_if_server_enable_and_user_admin,
|
||||
},
|
||||
domain::server_config::change_enable_server::change_enable_server,
|
||||
init::{Context, Error},
|
||||
};
|
||||
use poise::{
|
||||
@ -17,7 +14,8 @@ use tracing::instrument;
|
||||
slash_command,
|
||||
prefix_command,
|
||||
category = "server_config",
|
||||
guild_only = true
|
||||
guild_only = true,
|
||||
owners_only = true
|
||||
)]
|
||||
pub async fn init(
|
||||
ctx: Context<'_>,
|
||||
@ -29,38 +27,7 @@ pub async fn init(
|
||||
};
|
||||
let entity_name = ctx.data().entity_name.clone();
|
||||
let footer = CreateEmbedFooter::new(entity_name.clone());
|
||||
match check_if_server_enable_and_user_admin(guild.get(), ctx.author().id.get(), ctx.http())
|
||||
.await
|
||||
{
|
||||
Ok((ok, _)) => {
|
||||
if !ok {
|
||||
let embed = CreateEmbed::new()
|
||||
.title("You are not an admin")
|
||||
.color(colour::Color::RED)
|
||||
.footer(footer);
|
||||
if let Err(why) = ctx
|
||||
.send(CreateReply::default().embed(embed).ephemeral(true))
|
||||
.await
|
||||
{
|
||||
tracing::error!("Error sending message: {:?}", why);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
let embed = CreateEmbed::new()
|
||||
.title("You are not an admin")
|
||||
.color(colour::Color::RED)
|
||||
.footer(footer);
|
||||
if let Err(why) = ctx
|
||||
.send(CreateReply::default().embed(embed).ephemeral(true))
|
||||
.await
|
||||
{
|
||||
tracing::error!("Error sending message: {:?}", why);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let answer = match change_enable_server(guild.get(), enable).await {
|
||||
Ok(_) => CreateEmbed::new()
|
||||
.title("Server config initialized")
|
||||
|
Loading…
Reference in New Issue
Block a user