diff --git a/discord/auditlog.go b/discord/auditlog.go index 5f6cdd1..a04d197 100644 --- a/discord/auditlog.go +++ b/discord/auditlog.go @@ -26,7 +26,7 @@ type AuditLogEntry struct { // ID is the id of the entry. ID AuditLogEntryID `json:"id"` // TargetID is the id of the affected entity (webhook, user, role, etc.). - TargetID string `json:"target_id,omitempty"` + TargetID Snowflake `json:"target_id"` // Changes are the changes made to the TargetID. Changes []AuditLogChange `json:"changes,omitempty"` // UserID is the id of the user who made the changes. diff --git a/discord/channel.go b/discord/channel.go index 2faa34d..9705d8b 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -8,11 +8,14 @@ import ( // https://discord.com/developers/docs/resources/channel#channel-object type Channel struct { // ID is the id of this channel. - ID ChannelID `json:"id,string"` + ID ChannelID `json:"id"` + // GuildID is the id of the guild. + GuildID GuildID `json:"guild_id,omitempty"` + // Type is the type of channel. Type ChannelType `json:"type,omitempty"` - // GuildID is the id of the guild. - GuildID GuildID `json:"guild_id,string,omitempty"` + // NSFW specifies whether the channel is nsfw. + NSFW bool `json:"nsfw,omitempty"` // Position is the sorting position of the channel. Position int `json:"position,omitempty"` @@ -23,12 +26,10 @@ type Channel struct { Name string `json:"name,omitempty"` // Topic is the channel topic (0-1024 characters). Topic string `json:"topic,omitempty"` - // NSFW specifies whether the channel is nsfw. - NSFW bool `json:"nsfw,omitempty"` // LastMessageID is the id of the last message sent in this channel (may // not point to an existing or valid message). - LastMessageID MessageID `json:"last_message_id,string,omitempty"` + LastMessageID MessageID `json:"last_message_id,omitempty"` // VoiceBitrate is the bitrate (in bits) of the voice channel. VoiceBitrate uint `json:"bitrate,omitempty"` @@ -45,15 +46,15 @@ type Channel struct { // Icon is the icon hash. Icon Hash `json:"icon,omitempty"` // DMOwnerID is the id of the DM creator. - DMOwnerID UserID `json:"owner_id,string,omitempty"` + DMOwnerID UserID `json:"owner_id,omitempty"` // AppID is the application id of the group DM creator if it is // bot-created. - AppID AppID `json:"application_id,string,omitempty"` + AppID AppID `json:"application_id,omitempty"` // CategoryID is the id of the parent category for a channel (each parent // category can contain up to 50 channels). - CategoryID ChannelID `json:"parent_id,string,omitempty"` + CategoryID ChannelID `json:"parent_id,omitempty"` // LastPinTime is when the last pinned message was pinned. LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"` } diff --git a/discord/discord.go b/discord/discord.go index 496f377..52d7a4c 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -4,7 +4,7 @@ package discord // HasFlag is returns true if has is in the flag. In other words, it checks if -// has is OR'd into flag. This function could be used for different constants +// has is OR'ed into flag. This function could be used for different constants // such as Permission. func HasFlag(flag, has uint64) bool { return flag&has == has diff --git a/discord/emoji.go b/discord/emoji.go index 5f93b6a..61e9113 100644 --- a/discord/emoji.go +++ b/discord/emoji.go @@ -2,18 +2,40 @@ package discord import "strings" +// https://discord.com/developers/docs/resources/emoji#emoji-object type Emoji struct { - ID EmojiID `json:"id,string"` // NullSnowflake for unicode emojis - Name string `json:"name"` - - // These fields are optional + // ID is the ID of the Emoji. + // The ID will be NullSnowflake, if the Emoji is a Unicode emoji. + ID EmojiID `json:"id"` + // Name is the name of the emoji. + Name string `json:"name"` + // RoleIDs are the roles the emoji is whitelisted to. + // + // This field is only available for custom emojis. RoleIDs []RoleID `json:"roles,omitempty"` - User User `json:"user,omitempty"` + // User is the user that created the emoji. + // + // This field is only available for custom emojis. + User User `json:"user,omitempty"` + // RequireColons specifies whether the emoji must be wrapped in colons. + // + // This field is only available for custom emojis. RequireColons bool `json:"require_colons,omitempty"` - Managed bool `json:"managed,omitempty"` - Animated bool `json:"animated,omitempty"` + // Managed specifies whether the emoji is managed. + // + // This field is only available for custom emojis. + Managed bool `json:"managed,omitempty"` + // Animated specifies whether the emoji is animated. + // + // This field is only available for custom emojis. + Animated bool `json:"animated,omitempty"` + // Available specifies whether the emoji can be used. + // This may be false tue to loss of Server Boosts. + // + // This field is only available for custom emojis. + Available bool `json:"available,omitempty"` } // EmojiURL returns the URL of the emoji and auto-detects a suitable type. diff --git a/discord/guild.go b/discord/guild.go index e92b645..ceb3edc 100644 --- a/discord/guild.go +++ b/discord/guild.go @@ -3,7 +3,7 @@ package discord // https://discord.com/developers/docs/resources/guild#guild-object type Guild struct { // ID is the guild id. - ID GuildID `json:"id,string"` + ID GuildID `json:"id"` // Name is the guild name (2-100 characters, excluding trailing and leading // whitespace). Name string `json:"name"` @@ -18,27 +18,42 @@ type Guild struct { // Owner is true if the user is the owner of the guild. Owner bool `json:"owner,omitempty"` - // OwnerID is the id of owner. - OwnerID UserID `json:"owner_id,string"` - - // Permissions are the total permissions for the user in the guild - // (excludes overrides). - Permissions Permissions `json:"permissions,string,omitempty"` - - // VoiceRegion is the voice region id for the guild. - VoiceRegion string `json:"region"` - - // AFKChannelID is the id of the afk channel. - AFKChannelID ChannelID `json:"afk_channel_id,string,omitempty"` - // AFKTimeout is the afk timeout in seconds. - AFKTimeout Seconds `json:"afk_timeout"` + // Widget is true if the server widget is enabled. + Widget bool `json:"widget_enabled,omitempty"` + // SystemChannelFlags are the system channel flags. + SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"` // Verification is the verification level required for the guild. Verification Verification `json:"verification_level"` // Notification is the default message notifications level. Notification Notification `json:"default_message_notifications"` // ExplicitFilter is the explicit content filter level. ExplicitFilter ExplicitFilter `json:"explicit_content_filter"` + // NitroBoost is the premium tier (Server Boost level). + NitroBoost NitroBoost `json:"premium_tier"` + // MFA is the required MFA level for the guild. + MFA MFALevel `json:"mfa"` + + // OwnerID is the id of owner. + OwnerID UserID `json:"owner_id"` + // WidgetChannelID is the channel id that the widget will generate an + // invite to, or null if set to no invite. + WidgetChannelID ChannelID `json:"widget_channel_id,omitempty"` + // SystemChannelID is the the id of the channel where guild notices such as + // welcome messages and boost events are posted. + SystemChannelID ChannelID `json:"system_channel_id,omitempty"` + + // Permissions are the total permissions for the user in the guild + // (excludes overrides). + Permissions Permissions `json:"permissions,omitempty"` + + // VoiceRegion is the voice region id for the guild. + VoiceRegion string `json:"region"` + + // AFKChannelID is the id of the afk channel. + AFKChannelID ChannelID `json:"afk_channel_id,omitempty"` + // AFKTimeout is the afk timeout in seconds. + AFKTimeout Seconds `json:"afk_timeout"` // Roles are the roles in the guild. Roles []Role `json:"roles"` @@ -47,25 +62,10 @@ type Guild struct { // Features are the enabled guild features. Features []GuildFeature `json:"guild_features"` - // MFA is the required MFA level for the guild. - MFA MFALevel `json:"mfa"` - // AppID is the application id of the guild creator if it is bot-created. // // This field is nullable. - AppID AppID `json:"application_id,string,omitempty"` - - // Widget is true if the server widget is enabled. - Widget bool `json:"widget_enabled,omitempty"` - // WidgetChannelID is the channel id that the widget will generate an - // invite to, or null if set to no invite. - WidgetChannelID ChannelID `json:"widget_channel_id,string,omitempty"` - - // SystemChannelID is the the id of the channel where guild notices such as - // welcome messages and boost events are posted. - SystemChannelID ChannelID `json:"system_channel_id,string,omitempty"` - // SystemChannelFlags are the system channel flags. - SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"` + AppID AppID `json:"application_id,omitempty"` // RulesChannelID is the id of the channel where guilds with the "PUBLIC" // feature can display rules and/or guidelines. @@ -87,8 +87,6 @@ type Guild struct { // Banner is the banner hash. Banner Hash `json:"banner,omitempty"` - // NitroBoost is the premium tier (Server Boost level). - NitroBoost NitroBoost `json:"premium_tier"` // NitroBoosters is the number of boosts this guild currently has. NitroBoosters uint64 `json:"premium_subscription_count,omitempty"` @@ -276,20 +274,20 @@ func (g GuildPreview) DiscoverySplashURLWithType(t ImageType) string { // https://discord.com/developers/docs/topics/permissions#role-object type Role struct { // ID is the role id. - ID RoleID `json:"id,string"` + ID RoleID `json:"id"` // Name is the role name. Name string `json:"name"` - // Color is the integer representation of hexadecimal color code. - Color Color `json:"color"` - // Hoist specifies if this role is pinned in the user listing. - Hoist bool `json:"hoist"` + // Permissions is the permission bit set. + Permissions Permissions `json:"permissions"` + // Position is the position of this role. Position int `json:"position"` + // Color is the integer representation of hexadecimal color code. + Color Color `json:"color"` - // Permissions is the permission bit set. - Permissions Permissions `json:"permissions,string"` - + // Hoist specifies if this role is pinned in the user listing. + Hoist bool `json:"hoist"` // Manages specifies whether this role is managed by an integration. Managed bool `json:"managed"` // Mentionable specifies whether this role is mentionable. diff --git a/discord/message.go b/discord/message.go index 981ae00..9bcc1ac 100644 --- a/discord/message.go +++ b/discord/message.go @@ -11,13 +11,42 @@ import ( // https://discord.com/developers/docs/resources/channel#message-object type Message struct { // ID is the id of the message. - ID MessageID `json:"id,string"` + ID MessageID `json:"id"` + // ChannelID is the id of the channel the message was sent in. + ChannelID ChannelID `json:"channel_id"` + // GuildID is the id of the guild the message was sent in. + GuildID GuildID `json:"guild_id,omitempty"` + // Type is the type of message. Type MessageType `json:"type"` - // ChannelID is the id of the channel the message was sent in. - ChannelID ChannelID `json:"channel_id,string"` - // GuildID is the id of the guild the message was sent in. - GuildID GuildID `json:"guild_id,string,omitempty"` + + // Flags are the MessageFlags. + Flags MessageFlags `json:"flags"` + + // TTS specifies whether the was a TTS message. + TTS bool `json:"tts"` + // Pinned specifies whether the message is pinned. + Pinned bool `json:"pinned"` + + // MentionEveryone specifies whether the message mentions everyone. + MentionEveryone bool `json:"mention_everyone"` + // Mentions contains the users specifically mentioned in the message. + // + // The user objects in the mentions array will only have the partial + // member field present in MESSAGE_CREATE and MESSAGE_UPDATE events from + // text-based guild channels. + Mentions []GuildUser `json:"mentions"` + // MentionRoleIDs contains the ids of the roles specifically mentioned in + // the message. + MentionRoleIDs []RoleID `json:"mention_roles"` + // MentionChannels are the channels specifically mentioned in the message. + // + // Not all channel mentions in a message will appear in mention_channels. + // Only textual channels that are visible to everyone in a lurkable guild + // will ever be included. Only crossposted messages (via Channel Following) + // currently include mention_channels at all. If no mentions in the message + // meet these requirements, the slice will be empty. + MentionChannels []ChannelMention `json:"mention_channels,omitempty"` // Author is the author of the message. // @@ -39,32 +68,6 @@ type Message struct { // IsValid() will return false, if the messages hasn't been edited. EditedTimestamp Timestamp `json:"edited_timestamp,omitempty"` - // TTS specifies whether the was a TTS message. - TTS bool `json:"tts"` - // Pinned specifies whether the message is pinned. - Pinned bool `json:"pinned"` - - // Mentions contains the users specifically mentioned in the message. - // - // The user objects in the mentions array will only have the partial - // member field present in MESSAGE_CREATE and MESSAGE_UPDATE events from - // text-based guild channels. - Mentions []GuildUser `json:"mentions"` - // MentionEveryone specifies whether the message mentions everyone. - MentionEveryone bool `json:"mention_everyone"` - - // MentionRoleIDs contains the ids of the roles specifically mentioned in - // the message. - MentionRoleIDs []RoleID `json:"mention_roles"` - // MentionChannels are the channels specifically mentioned in the message. - // - // Not all channel mentions in a message will appear in mention_channels. - // Only textual channels that are visible to everyone in a lurkable guild - // will ever be included. Only crossposted messages (via Channel Following) - // currently include mention_channels at all. If no mentions in the message - // meet these requirements, the slice will be empty. - MentionChannels []ChannelMention `json:"mention_channels,omitempty"` - // Attachments contains any attached files. Attachments []Attachment `json:"attachments"` // Embeds contains any embedded content. @@ -77,7 +80,7 @@ type Message struct { // WebhookID contains the ID of the webhook, if the message was generated // by a webhook. - WebhookID WebhookID `json:"webhook_id,string,omitempty"` + WebhookID WebhookID `json:"webhook_id,omitempty"` // Activity is sent with Rich Presence-related chat embeds. Activity *MessageActivity `json:"activity,omitempty"` @@ -93,8 +96,6 @@ type Message struct { // non-null, it is a message object ReferencedMessage *Message `json:"referenced_message,omitempty"` - // Flags are the MessageFlags. - Flags MessageFlags `json:"flags"` // Stickers contains the sticker sent with the message. Stickers []Sticker `json:"stickers,omitempty"` } @@ -321,7 +322,7 @@ type MessageReference struct { // https://discord.com/developers/docs/resources/channel#attachment-object type Attachment struct { // ID is the attachment id. - ID AttachmentID `json:"id,string"` + ID AttachmentID `json:"id"` // Filename is the name of file attached. Filename string `json:"filename"` // Size is the size of file in bytes. diff --git a/discord/user.go b/discord/user.go index a03b3f7..ac6362c 100644 --- a/discord/user.go +++ b/discord/user.go @@ -5,7 +5,7 @@ import ( ) type User struct { - ID UserID `json:"id,string"` + ID UserID `json:"id"` Username string `json:"username"` Discriminator string `json:"discriminator"` Avatar Hash `json:"avatar"` @@ -15,15 +15,15 @@ type User struct { Bot bool `json:"bot,omitempty"` MFA bool `json:"mfa_enabled,omitempty"` + Nitro UserNitro `json:"premium_type,omitempty"` + Flags UserFlags `json:"flags,omitempty"` + PublicFlags UserFlags `json:"public_flags,omitempty"` + DiscordSystem bool `json:"system,omitempty"` EmailVerified bool `json:"verified,omitempty"` Locale string `json:"locale,omitempty"` Email string `json:"email,omitempty"` - - Flags UserFlags `json:"flags,omitempty"` - PublicFlags UserFlags `json:"public_flags,omitempty"` - Nitro UserNitro `json:"premium_type,omitempty"` } func (u User) Mention() string { @@ -127,12 +127,16 @@ const ( ) type Activity struct { - Name string `json:"name"` + Name string `json:"name"` + URL URL `json:"url,omitempty"` + Type ActivityType `json:"type"` - URL URL `json:"url,omitempty"` // User only + Instance bool `json:"instance,omitempty"` + Flags ActivityFlags `json:"flags,omitempty"` + CreatedAt UnixTimestamp `json:"created_at,omitempty"` Timestamps *ActivityTimestamp `json:"timestamps,omitempty"` @@ -145,9 +149,6 @@ type Activity struct { Assets *ActivityAssets `json:"assets,omitempty"` Secrets *ActivitySecrets `json:"secrets,omitempty"` - Instance bool `json:"instance,omitempty"` - Flags ActivityFlags `json:"flags,omitempty"` - // Undocumented fields SyncID string `json:"sync_id,omitempty"` SessionID string `json:"session_id,omitempty"` diff --git a/discord/voice.go b/discord/voice.go index 2561b41..59d3683 100644 --- a/discord/voice.go +++ b/discord/voice.go @@ -2,10 +2,10 @@ package discord type VoiceState struct { // GuildID isn't available from the Guild struct. - GuildID GuildID `json:"guild_id,string"` + GuildID GuildID `json:"guild_id"` - ChannelID ChannelID `json:"channel_id,string"` - UserID UserID `json:"user_id,string"` + ChannelID ChannelID `json:"channel_id"` + UserID UserID `json:"user_id"` Member *Member `json:"member,omitempty"` SessionID string `json:"session_id"`