check perms properly

This commit is contained in:
jellywx 2021-05-20 21:58:17 +01:00
parent 0c97baabb6
commit a6b98cd450
2 changed files with 260 additions and 269 deletions

504
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1224,9 +1224,30 @@ async fn delete_sound(ctx: &Context, msg: &Message, args: Args) -> CommandResult
)
.await?;
} else {
let has_perms = {
if let Ok(member) = msg.member(&ctx).await {
if let Ok(perms) = member.permissions(&ctx).await {
perms.manage_guild()
} else {
false
}
} else {
false
}
};
if sound.uploader_id == Some(uid) || has_perms {
sound.delete(pool).await?;
msg.channel_id.say(&ctx, "Sound has been deleted").await?;
} else {
msg.channel_id
.say(
&ctx,
"Only server admins can delete sounds uploaded by other users.",
)
.await?;
}
}
}