Enforce permission check for expanding.

master
ALI Hamza 2021-09-07 18:14:50 +07:00
parent 4480b1ed6b
commit d67c3d9a63
Signed by: hamza
GPG Key ID: 22473A32291F8CB6
1 changed files with 8 additions and 4 deletions

@ -23,7 +23,7 @@ var (
cannotExpand = "You cannot expand this embed."
privilegedRoles = map[discord.RoleID]struct{}{
// Gopher Herder ID on discord.gg/golang
// Gopher Herder ID on discord.gg/golang.
370280974593818644: {},
}
)
@ -146,9 +146,13 @@ func (b *botState) onDocsComponent(e *gateway.InteractionCreateEvent, data *inte
},
}
// admin + priviledged only
// only check admin here to reduce total api calls
// Admin + privileged only.
// (Only check admin here to reduce total API calls).
case "expand":
if !isAdmin() {
embed = failEmbed("Error", cannotExpand)
break
}
embed, data.full = b.onDocs(e, data.query, true), true
components = &[]discord.Component{
discord.ActionRowComponent{
@ -173,7 +177,7 @@ func (b *botState) onDocsComponent(e *gateway.InteractionCreateEvent, data *inte
}
if e.GuildID != discord.NullGuildID {
// check admin last
// Check admin last.
if e.User.ID != data.user.ID && !hasRole && !isAdmin() {
embed = failEmbed("Error", notOwner)
}