feat: change commands to use the "Manage Server" permission instead of just admin.
All checks were successful
On_Push / lint_clippy (push) Successful in 20s
On_Push / lint_fmt (push) Successful in 34s
On_Push / build (push) Successful in 3m32s
On_Push / deploy (push) Successful in 26s

This measn that the commands only show up if you can manage teh server
This commit is contained in:
silver 2025-02-26 15:55:42 +00:00
parent 09ce45f70f
commit 7406f0e620
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D
4 changed files with 21 additions and 73 deletions

View file

@ -3,15 +3,9 @@ use serenity::{builder::CreateCommand, client::Context};
use skynet_discord_bot::common::database::{get_server_config, DataBase, Servers};
use skynet_discord_bot::common::set_roles::normal::update_server;
use skynet_discord_bot::common::wolves::cns::get_wolves;
use skynet_discord_bot::is_admin;
use sqlx::{Error, Pool, Sqlite};
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
// check if user has high enough permisssions
if let Some(msg) = is_admin(command, ctx).await {
return msg;
}
let wolves_api = if let Some(CommandDataOption {
value: CommandDataOptionValue::String(key),
..
@ -83,6 +77,7 @@ pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
pub fn register() -> CreateCommand {
CreateCommand::new("add")
.description("Enable the bot for this discord")
.default_member_permissions(serenity::model::Permissions::MANAGE_GUILD)
.add_option(CreateCommandOption::new(CommandOptionType::String, "api_key", "UL Wolves API Key").required(true))
.add_option(CreateCommandOption::new(CommandOptionType::Role, "role_current", "Role for Current members").required(true))
.add_option(CreateCommandOption::new(CommandOptionType::Channel, "bot_channel", "Safe space for folks to use the bot commands.").required(true))