Use absolute values for permission constants

We define our permissions constants based on Discord's values,
and thus the use of `iota` is fragile, makes docs harder to read,
and makes changes touching these constants harder to review.
Here, we now use the full 64-bit representation of each constant,
which both removes the implicit ordering dependencies and makes
the values easier to immediately see.
This commit is contained in:
Carson Hoffman 2021-04-09 15:34:05 -04:00
parent 30251cf325
commit 843c765ae3
No known key found for this signature in database
GPG key ID: 05B660CB452C657F

View file

@ -1158,48 +1158,48 @@ type IdentifyProperties struct {
// Constants for the different bit offsets of text channel permissions // Constants for the different bit offsets of text channel permissions
const ( const (
// Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels // Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels
PermissionReadMessages = 1 << (iota + 10) PermissionReadMessages = 0x0000000000000400
PermissionSendMessages PermissionSendMessages = 0x0000000000000800
PermissionSendTTSMessages PermissionSendTTSMessages = 0x0000000000001000
PermissionManageMessages PermissionManageMessages = 0x0000000000002000
PermissionEmbedLinks PermissionEmbedLinks = 0x0000000000004000
PermissionAttachFiles PermissionAttachFiles = 0x0000000000008000
PermissionReadMessageHistory PermissionReadMessageHistory = 0x0000000000010000
PermissionMentionEveryone PermissionMentionEveryone = 0x0000000000020000
PermissionUseExternalEmojis PermissionUseExternalEmojis = 0x0000000000040000
) )
// Constants for the different bit offsets of voice permissions // Constants for the different bit offsets of voice permissions
const ( const (
PermissionVoiceConnect = 1 << (iota + 20) PermissionVoicePrioritySpeaker = 0x0000000000000100
PermissionVoiceSpeak PermissionVoiceConnect = 0x0000000000100000
PermissionVoiceMuteMembers PermissionVoiceSpeak = 0x0000000000200000
PermissionVoiceDeafenMembers PermissionVoiceMuteMembers = 0x0000000000400000
PermissionVoiceMoveMembers PermissionVoiceDeafenMembers = 0x0000000000800000
PermissionVoiceUseVAD PermissionVoiceMoveMembers = 0x0000000001000000
PermissionVoicePrioritySpeaker = 1 << (iota + 2) PermissionVoiceUseVAD = 0x0000000002000000
) )
// Constants for general management. // Constants for general management.
const ( const (
PermissionChangeNickname = 1 << (iota + 26) PermissionChangeNickname = 0x0000000004000000
PermissionManageNicknames PermissionManageNicknames = 0x0000000008000000
PermissionManageRoles PermissionManageRoles = 0x0000000010000000
PermissionManageWebhooks PermissionManageWebhooks = 0x0000000020000000
PermissionManageEmojis PermissionManageEmojis = 0x0000000040000000
) )
// Constants for the different bit offsets of general permissions // Constants for the different bit offsets of general permissions
const ( const (
PermissionCreateInstantInvite = 1 << iota PermissionCreateInstantInvite = 0x0000000000000001
PermissionKickMembers PermissionKickMembers = 0x0000000000000002
PermissionBanMembers PermissionBanMembers = 0x0000000000000004
PermissionAdministrator PermissionAdministrator = 0x0000000000000008
PermissionManageChannels PermissionManageChannels = 0x0000000000000010
PermissionManageServer PermissionManageServer = 0x0000000000000020
PermissionAddReactions PermissionAddReactions = 0x0000000000000040
PermissionViewAuditLogs PermissionViewAuditLogs = 0x0000000000000080
PermissionViewChannel = 1 << (iota + 2) PermissionViewChannel = 0x0000000000000400
PermissionAllText = PermissionViewChannel | PermissionAllText = PermissionViewChannel |
PermissionSendMessages | PermissionSendMessages |