Skip to content

Commit

Permalink
moved permission check outside
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwai committed Feb 18, 2024
1 parent 63d77cc commit bc99d18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/bot/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,11 @@ pub async fn setup(
number: Option<u32>,
#[rest] rest: Option<String>,
) -> Result<(), Error> {
// Check permissions
if !checks::is_owner(ctx).await && !checks::is_admin(ctx).await {
ctx.say("Missing permissions, requires admin permissions")
.await?;
return Ok(());
}
setup_command::setup(ctx, role_mention, channel_mention, flag, number, rest).await
}
9 changes: 1 addition & 8 deletions src/bot/setup_command.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use poise::serenity_prelude::{GuildChannel, GuildId, Mentionable, Role};
use time::Time;

use crate::bot::{checks, Context, Error};
use crate::bot::{Context, Error};
use crate::mysql_lib;
use crate::mysql_lib::{DatabaseGuild, NewGuild};

Expand Down Expand Up @@ -1480,13 +1480,6 @@ pub async fn setup(
number = Some(flag.into());
}
}
// Check permissions
if !checks::is_owner(ctx).await && !checks::is_admin(ctx).await {
ctx.say("Missing permissions, requires admin permissions")
.await?;
return Ok(());
}

let guild_id = ctx.guild_id().unwrap();

let db = &ctx.data().database_pool;
Expand Down

0 comments on commit bc99d18

Please sign in to comment.