From 0eacf465a3ecebca4b5f6a6d7c5c3a5575993d81 Mon Sep 17 00:00:00 2001 From: jellywx Date: Tue, 26 Jan 2021 12:23:28 +0000 Subject: [PATCH] fix permission checks --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/framework.rs | 6 +++--- src/main.rs | 6 ++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11fb074..e20ffa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1894,7 +1894,7 @@ dependencies = [ [[package]] name = "soundfx-rs" -version = "1.1.0" +version = "1.1.1" dependencies = [ "dotenv", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index dfba20f..fde6886 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soundfx-rs" -version = "1.1.0" +version = "1.1.1" authors = ["jellywx "] edition = "2018" diff --git a/src/framework.rs b/src/framework.rs index 1684f1f..1cf77a0 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -44,7 +44,7 @@ impl Command { } else { let permissions = guild.member_permissions(&ctx, &member.user).await.unwrap(); - if permissions.manage_guild() && self.required_perms == PermissionLevel::Managed { + if permissions.manage_guild() { return true; } @@ -310,9 +310,9 @@ impl Framework for RegexFramework { ) .await .unwrap(); - } else if command.required_perms == PermissionLevel::Restricted { - let _ = msg.channel_id.say(&ctx, "You must either be an Admin or have a role specified in `?roles` to do this command").await; } else if command.required_perms == PermissionLevel::Managed { + let _ = msg.channel_id.say(&ctx, "You must either be an Admin or have a role specified in `?roles` to do this command").await; + } else if command.required_perms == PermissionLevel::Restricted { let _ = msg .channel_id .say(&ctx, "You must be an Admin to do this command") diff --git a/src/main.rs b/src/main.rs index b30a93d..fe51da7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -327,6 +327,7 @@ async fn main() -> Result<(), Box> { } #[command] +#[permission_level(Managed)] async fn play(ctx: &Context, msg: &Message, args: Args) -> CommandResult { let guild = match msg.guild(&ctx.cache).await { Some(guild) => guild, @@ -447,6 +448,7 @@ There is a maximum sound limit per user. This can be removed by donating at http } #[command] +#[permission_level(Managed)] async fn change_volume(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { let guild = match msg.guild(&ctx.cache).await { Some(guild) => guild, @@ -495,6 +497,7 @@ async fn change_volume(ctx: &Context, msg: &Message, mut args: Args) -> CommandR } #[command] +#[permission_level(Restricted)] async fn change_prefix(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { let guild = match msg.guild(&ctx.cache).await { Some(guild) => guild, @@ -692,6 +695,7 @@ async fn upload_new_sound(ctx: &Context, msg: &Message, args: Args) -> CommandRe } #[command] +#[permission_level(Restricted)] async fn set_allowed_roles(ctx: &Context, msg: &Message, args: Args) -> CommandResult { let guild_id = *msg.guild_id.unwrap().as_u64(); @@ -1105,6 +1109,7 @@ WHERE } #[command] +#[permission_level(Managed)] async fn stop_playing(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { let voice_manager = songbird::get(ctx).await.unwrap(); @@ -1114,6 +1119,7 @@ async fn stop_playing(ctx: &Context, msg: &Message, _args: Args) -> CommandResul } #[command] +#[permission_level(Managed)] async fn allow_greet_sounds(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { let guild = match msg.guild(&ctx.cache).await { Some(guild) => guild,