mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-01-05 19:57:02 +00:00
Discord: Fixed redundant and broken OverwriteType
This commit is contained in:
parent
196cab2105
commit
795cbdef53
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue