feat: change commands to use the "Manage Server" permission instead of just admin.

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 untrusted user: silver
GPG key ID: 36F93D61BAD3FD7D
4 changed files with 21 additions and 73 deletions

View file

@ -1,7 +1,6 @@
use serenity::client::Context;
use skynet_discord_bot::common::database::{DataBase, RoleAdder};
use skynet_discord_bot::is_admin;
use sqlx::{Error, Pool, Sqlite};
pub mod edit {
@ -9,11 +8,6 @@ pub mod edit {
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, CreateCommand, CreateCommandOption};
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 role_a = if let Some(CommandDataOption {
value: CommandDataOptionValue::Role(role),
..
@ -110,6 +104,7 @@ pub mod edit {
pub fn register() -> CreateCommand {
CreateCommand::new("roles_adder")
.description("Combine roles together to an new one")
.default_member_permissions(serenity::model::Permissions::MANAGE_GUILD)
.add_option(CreateCommandOption::new(CommandOptionType::Role, "role_a", "A role you want to add to Role B").required(true))
.add_option(CreateCommandOption::new(CommandOptionType::Role, "role_b", "A role you want to add to Role A").required(true))
.add_option(CreateCommandOption::new(CommandOptionType::Role, "role_c", "Sum of A and B").required(true))