fix permission checks

This commit is contained in:
jellywx 2021-01-26 12:23:28 +00:00
parent 1dc81837e0
commit 0eacf465a3
4 changed files with 11 additions and 5 deletions

2
Cargo.lock generated
View File

@ -1894,7 +1894,7 @@ dependencies = [
[[package]]
name = "soundfx-rs"
version = "1.1.0"
version = "1.1.1"
dependencies = [
"dotenv",
"lazy_static",

View File

@ -1,6 +1,6 @@
[package]
name = "soundfx-rs"
version = "1.1.0"
version = "1.1.1"
authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018"

View File

@ -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")

View File

@ -327,6 +327,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
}
#[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,