reactions are permission gated properly so they work with different subsets of permissions

This commit is contained in:
2020-11-23 16:04:42 +00:00
parent 3c1fe1f091
commit 55437b76eb
2 changed files with 41 additions and 9 deletions

View File

@@ -290,9 +290,9 @@ impl RegexFramework {
}
enum PermissionCheck {
None, // No permissions
Basic(bool, bool), // Send + Embed permissions (sufficient to reply)
All, // Above + Manage Webhooks (sufficient to operate)
None, // No permissions
Basic(bool, bool, bool, bool), // Send + Embed permissions (sufficient to reply)
All, // Above + Manage Webhooks (sufficient to operate)
}
#[async_trait]
@@ -317,6 +317,8 @@ impl Framework for RegexFramework {
PermissionCheck::Basic(
guild_perms.manage_webhooks(),
channel_perms.embed_links(),
channel_perms.add_reactions(),
channel_perms.manage_messages(),
)
} else {
PermissionCheck::None
@@ -414,16 +416,26 @@ impl Framework for RegexFramework {
}
}
PermissionCheck::Basic(manage_webhooks, embed_links) => {
PermissionCheck::Basic(
manage_webhooks,
embed_links,
add_reactions,
manage_messages,
) => {
let response = lm
.get(&language, "no_perms_general")
.replace(
"{manage_webhooks}",
if manage_webhooks { "" } else { "" },
)
.replace("{embed_links}", if embed_links { "" } else { "" })
.replace(
"{embed_links}",
if embed_links { "" } else { "" },
"{add_reactions}",
if add_reactions { "" } else { "" },
)
.replace(
"{manage_messages}",
if manage_messages { "" } else { "" },
);
let _ = msg.channel_id.say(&ctx, response).await;