From d67c3d9a63452049f6e1ce754ae3c2be3b04a7fa Mon Sep 17 00:00:00 2001 From: Hamza Ali Date: Tue, 7 Sep 2021 18:14:50 +0700 Subject: [PATCH] Enforce permission check for expanding. --- doc.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc.go b/doc.go index d505236..b53e3c6 100644 --- a/doc.go +++ b/doc.go @@ -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) }