diff --git a/discord/auditlog.go b/discord/auditlog.go index e1de2ea..1a6bc70 100644 --- a/discord/auditlog.go +++ b/discord/auditlog.go @@ -116,7 +116,7 @@ type AuditEntryInfo struct { // // Events: CHANNEL_OVERWRITE_CREATE, CHANNEL_OVERWRITE_UPDATE, // CHANNEL_OVERWRITE_DELETE - Type ChannelOverwritten `json:"type,omitempty"` + Type OverwriteType `json:"type,omitempty"` // RoleName is the name of the role if type is "role". // // Events: CHANNEL_OVERWRITE_CREATE, CHANNEL_OVERWRITE_UPDATE, @@ -124,15 +124,6 @@ type AuditEntryInfo struct { RoleName string `json:"role_name,omitempty"` } -// ChannelOverwritten is the type of overwritten entity in -// (AuditEntryInfo).Type. -type ChannelOverwritten string - -const ( - MemberChannelOverwritten ChannelOverwritten = "member" - RoleChannelOverwritten ChannelOverwritten = "role" -) - // AuditLogChange is a single key type to changed value audit log entry. The // type can be found in the key's comment. Values can be nil. // diff --git a/discord/channel.go b/discord/channel.go index 5668ae6..b9df502 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -104,7 +104,7 @@ var ( type Overwrite struct { // ID is the role or user id. ID Snowflake `json:"id"` - // Type is either "role" or "member". + // Type indicates the entity overwritten: role or member. Type OverwriteType `json:"type,string"` // Allow is a permission bit set for granted permissions. Allow Permissions `json:"allow,string"` @@ -112,6 +112,8 @@ type Overwrite struct { Deny Permissions `json:"deny,string"` } +// OverwriteType is an enumerated type to indicate the entity being overwritten: +// role or member type OverwriteType uint8 const ( diff --git a/discord/permission.go b/discord/permission.go index 6444a66..5e7be27 100644 --- a/discord/permission.go +++ b/discord/permission.go @@ -157,7 +157,7 @@ func CalcOverwrites(guild Guild, channel Channel, member Member) Permissions { for _, overwrite := range channel.Permissions { for _, id := range member.RoleIDs { - if id == RoleID(overwrite.ID) && overwrite.Type == "role" { + if id == RoleID(overwrite.ID) && overwrite.Type == OverwriteRole { deny |= overwrite.Deny allow |= overwrite.Allow break