1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-06-30 00:26:15 +00:00

discord: Use consts for Discord constants

This commit is contained in:
unknown 2021-05-21 07:12:53 +01:00 committed by diamondburned
parent c880cb2fc8
commit f5b3e3972b
4 changed files with 107 additions and 91 deletions

View file

@ -92,24 +92,24 @@ func (ch Channel) IconURLWithType(t ImageType) string {
type ChannelType uint8
// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
var (
const (
// GuildText is a text channel within a server.
GuildText ChannelType = 0
GuildText ChannelType = iota
// DirectMessage is a direct message between users.
DirectMessage ChannelType = 1
DirectMessage
// GuildVoice is a voice channel within a server.
GuildVoice ChannelType = 2
GuildVoice
// GroupDM is a direct message between multiple users.
GroupDM ChannelType = 3
GroupDM
// GuildCategory is an organizational category that contains up to 50
// channels.
GuildCategory ChannelType = 4
GuildCategory
// GuildNews is a channel that users can follow and crosspost into their
// own server.
GuildNews ChannelType = 5
GuildNews
// GuildStore is a channel in which game developers can sell their game on
// Discord.
GuildStore ChannelType = 6
GuildStore
)
// https://discord.com/developers/docs/resources/channel#overwrite-object

View file

@ -77,17 +77,18 @@ const (
// ExplicitFilter is the explicit content filter level of a guild.
type ExplicitFilter enum.Enum
// NullExplicitFilter serialized to JSON null.
// This should only be used on nullable fields.
const NullExplicitFilter ExplicitFilter = enum.Null
// https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
var (
// NullExplicitFilter serialized to JSON null.
// This should only be used on nullable fields.
NullExplicitFilter ExplicitFilter = enum.Null
const (
// NoContentFilter disables content filtering for the guild.
NoContentFilter ExplicitFilter = 0
NoContentFilter ExplicitFilter = iota
// MembersWithoutRoles filters only members without roles.
MembersWithoutRoles ExplicitFilter = 1
MembersWithoutRoles
// AllMembers enables content filtering for all members.
AllMembers ExplicitFilter = 2
AllMembers
)
func (f *ExplicitFilter) UnmarshalJSON(b []byte) error {
@ -104,15 +105,16 @@ func (f ExplicitFilter) MarshalJSON() ([]byte, error) {
// Notification is the default message notification level of a guild.
type Notification enum.Enum
// NullNotification serialized to JSON null.
// This should only be used on nullable fields.
const NullNotification Notification = enum.Null
// https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
var (
// NullNotification serialized to JSON null.
// This should only be used on nullable fields.
NullNotification Notification = enum.Null
const (
// AllMessages sends notifications for all messages.
AllMessages Notification = 0
AllMessages Notification = iota
// OnlyMentions sends notifications only on mention.
OnlyMentions Notification = 1
OnlyMentions
)
func (n *Notification) UnmarshalJSON(b []byte) error {
@ -127,24 +129,25 @@ func (n Notification) MarshalJSON() ([]byte, error) { return enum.ToJSON(enum.En
// Verification is the verification level required for a guild.
type Verification enum.Enum
// NullVerification serialized to JSON null.
// This should only be used on nullable fields.
const NullVerification Verification = enum.Null
// https://discord.com/developers/docs/resources/guild#guild-object-verification-level
var (
// NullVerification serialized to JSON null.
// This should only be used on nullable fields.
NullVerification Verification = enum.Null
const (
// NoVerification required no verification.
NoVerification Verification = 0
NoVerification Verification = iota
// LowVerification requires a verified email
LowVerification Verification = 1
LowVerification
// MediumVerification requires the user be registered for at least 5
// minutes.
MediumVerification Verification = 2
MediumVerification
// HighVerification requires the member be in the server for more than 10
// minutes.
HighVerification Verification = 3
HighVerification
// VeryHighVerification requires the member to have a verified phone
// number.
VeryHighVerification Verification = 4
VeryHighVerification
)
func (v *Verification) UnmarshalJSON(b []byte) error {
@ -169,9 +172,9 @@ const (
type ExpireBehavior uint8
// https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
var (
const (
// RemoveRole removes the role of the subscriber.
RemoveRole ExpireBehavior = 0
RemoveRole ExpireBehavior = iota
// Kick kicks the subscriber from the guild.
Kick ExpireBehavior = 1
Kick
)

View file

@ -118,46 +118,60 @@ type MessageType uint8
// https://discord.com/developers/docs/resources/channel#message-object-message-types
const (
DefaultMessage MessageType = 0
RecipientAddMessage MessageType = 1
RecipientRemoveMessage MessageType = 2
CallMessage MessageType = 3
ChannelNameChangeMessage MessageType = 4
ChannelIconChangeMessage MessageType = 5
ChannelPinnedMessage MessageType = 6
GuildMemberJoinMessage MessageType = 7
NitroBoostMessage MessageType = 8
NitroTier1Message MessageType = 9
NitroTier2Message MessageType = 10
NitroTier3Message MessageType = 11
ChannelFollowAddMessage MessageType = 12
GuildDiscoveryDisqualifiedMessage MessageType = 14
GuildDiscoveryRequalifiedMessage MessageType = 15
InlinedReplyMessage MessageType = 19
ApplicationCommandMessage MessageType = 20
DefaultMessage MessageType = iota
RecipientAddMessage
RecipientRemoveMessage
CallMessage
ChannelNameChangeMessage
ChannelIconChangeMessage
ChannelPinnedMessage
GuildMemberJoinMessage
NitroBoostMessage
NitroTier1Message
NitroTier2Message
NitroTier3Message
ChannelFollowAddMessage
_
GuildDiscoveryDisqualifiedMessage
GuildDiscoveryRequalifiedMessage
GuildDiscoveryGracePeriodInitialWarning
GuildDiscoveryGracePeriodFinalWarning
_
InlinedReplyMessage
ApplicationCommandMessage
)
type MessageFlags enum.Enum
// NullMessage is the JSON null value of MessageFlags.
const NullMessage MessageFlags = enum.Null
// https://discord.com/developers/docs/resources/channel#message-object-message-types
var (
// NullMessage is the JSON null value of MessageFlags.
NullMessage MessageFlags = enum.Null
const (
// CrosspostedMessage specifies whether the message has been published to
// subscribed channels (via Channel Following).
CrosspostedMessage MessageFlags = 1
CrosspostedMessage MessageFlags = 1 << iota
// MessageIsCrosspost specifies whether the message originated from a
// message in another channel (via Channel Following).
MessageIsCrosspost MessageFlags = 2
MessageIsCrosspost
// SuppressEmbeds specifies whether to not include any embeds when
// serializing the message.
SuppressEmbeds MessageFlags = 4
SuppressEmbeds
// SourceMessageDeleted specifies whether the source message for the
// crosspost has been deleted (via Channel Following).
SourceMessageDeleted MessageFlags = 8
SourceMessageDeleted
// UrgentMessage specifies whether the message came from the urgent message
// system.
UrgentMessage MessageFlags = 16
UrgentMessage
// MessageHasThread specifies whether the message has an associated thread
// with the same id as the message
MessageHasThread
// EphemeralMessage specifies whether the message is only visible to
// the user who invoked the Interaction
EphemeralMessage
// MessageLoading specifies whether the message is an Interaction Response
// and the bot is "thinking"
MessageLoading
)
// https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure

View file

@ -2,72 +2,71 @@ package discord
type Permissions uint64
var (
const (
// Allows creation of instant invites
PermissionCreateInstantInvite Permissions = 1 << 0
PermissionCreateInstantInvite Permissions = 1 << iota
// Allows kicking members
PermissionKickMembers Permissions = 1 << 1
PermissionKickMembers
// Allows banning members
PermissionBanMembers Permissions = 1 << 2
PermissionBanMembers
// Allows all permissions and bypasses channel permission overwrites
PermissionAdministrator Permissions = 1 << 3
PermissionAdministrator
// Allows management and editing of channels
PermissionManageChannels Permissions = 1 << 4
PermissionManageChannels
// Allows management and editing of the guild
PermissionManageGuild Permissions = 1 << 5
PermissionManageGuild
// Allows for the addition of reactions to messages
PermissionAddReactions Permissions = 1 << 6
PermissionAddReactions
// Allows for viewing of audit logs
PermissionViewAuditLog Permissions = 1 << 7
PermissionViewAuditLog
// Allows for using priority speaker in a voice channel
PermissionPrioritySpeaker Permissions = 1 << 8
PermissionPrioritySpeaker
// Allows the user to go live
PermissionStream Permissions = 1 << 9
PermissionStream
// Allows guild members to view a channel, which includes reading messages
// in text channels
PermissionViewChannel Permissions = 1 << 10
PermissionViewChannel
// Allows for sending messages in a channel
PermissionSendMessages Permissions = 1 << 11
PermissionSendMessages
// Allows for sending of /tts messages
PermissionSendTTSMessages Permissions = 1 << 12
PermissionSendTTSMessages
// Allows for deletion of other users messages
PermissionManageMessages Permissions = 1 << 13
PermissionManageMessages
// Links sent by users with this permission will be auto-embedded
PermissionEmbedLinks Permissions = 1 << 14
PermissionEmbedLinks
// Allows for uploading images and files
PermissionAttachFiles Permissions = 1 << 15
PermissionAttachFiles
// Allows for reading of message history
PermissionReadMessageHistory Permissions = 1 << 16
PermissionReadMessageHistory
// Allows for using the @everyone tag to notify all users in a channel,
// and the @here tag to notify all online users in a channel
PermissionMentionEveryone Permissions = 1 << 17
PermissionMentionEveryone
// Allows the usage of custom emojis from other servers
PermissionUseExternalEmojis Permissions = 1 << 18
PermissionUseExternalEmojis
// ?
_
// Allows for joining of a voice channel
PermissionConnect Permissions = 1 << 20
PermissionConnect
// Allows for speaking in a voice channel
PermissionSpeak Permissions = 1 << 21
PermissionSpeak
// Allows for muting members in a voice channel
PermissionMuteMembers Permissions = 1 << 22
PermissionMuteMembers
// Allows for deafening of members in a voice channel
PermissionDeafenMembers Permissions = 1 << 23
PermissionDeafenMembers
// Allows for moving of members between voice channels
PermissionMoveMembers Permissions = 1 << 24
PermissionMoveMembers
// Allows for using voice-activity-detection in a voice channel
PermissionUseVAD Permissions = 1 << 25
PermissionUseVAD
// Allows for modification of own nickname
PermissionChangeNickname Permissions = 1 << 26
PermissionChangeNickname
// Allows for modification of other users nicknames
PermissionManageNicknames Permissions = 1 << 27
PermissionManageNicknames
// Allows management and editing of roles
PermissionManageRoles Permissions = 1 << 28
PermissionManageRoles
// Allows management and editing of webhooks
PermissionManageWebhooks Permissions = 1 << 29
PermissionManageWebhooks
// Allows management and editing of emojis
PermissionManageEmojis Permissions = 1 << 30
PermissionManageEmojis
PermissionAllText = 0 |
PermissionViewChannel |