diff options
author | Jordan <me@jordan.im> | 2023-08-18 00:08:21 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2023-08-18 00:08:21 -0700 |
commit | 61553158764c6801578076c72d8bffb423e343cc (patch) | |
tree | 5d45cf4b6699eebf01e9f2b6ac9ff0000819ebd2 /vendor/github.com/bwmarrin/discordgo/structs.go | |
parent | 001a042ccba1c3faf340d8217ee8d15efa60dc05 (diff) | |
download | keep-61553158764c6801578076c72d8bffb423e343cc.tar.gz keep-61553158764c6801578076c72d8bffb423e343cc.zip |
misc: go get -u; go mod tidy; go mod vendor
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo/structs.go')
-rw-r--r-- | vendor/github.com/bwmarrin/discordgo/structs.go | 302 |
1 files changed, 227 insertions, 75 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/structs.go b/vendor/github.com/bwmarrin/discordgo/structs.go index 26f507a..2dad321 100644 --- a/vendor/github.com/bwmarrin/discordgo/structs.go +++ b/vendor/github.com/bwmarrin/discordgo/structs.go @@ -17,7 +17,6 @@ import ( "math" "net/http" "regexp" - "strings" "sync" "time" @@ -156,6 +155,38 @@ type Application struct { Flags int `json:"flags,omitempty"` } +// ApplicationRoleConnectionMetadataType represents the type of application role connection metadata. +type ApplicationRoleConnectionMetadataType int + +// Application role connection metadata types. +const ( + ApplicationRoleConnectionMetadataIntegerLessThanOrEqual ApplicationRoleConnectionMetadataType = 1 + ApplicationRoleConnectionMetadataIntegerGreaterThanOrEqual ApplicationRoleConnectionMetadataType = 2 + ApplicationRoleConnectionMetadataIntegerEqual ApplicationRoleConnectionMetadataType = 3 + ApplicationRoleConnectionMetadataIntegerNotEqual ApplicationRoleConnectionMetadataType = 4 + ApplicationRoleConnectionMetadataDatetimeLessThanOrEqual ApplicationRoleConnectionMetadataType = 5 + ApplicationRoleConnectionMetadataDatetimeGreaterThanOrEqual ApplicationRoleConnectionMetadataType = 6 + ApplicationRoleConnectionMetadataBooleanEqual ApplicationRoleConnectionMetadataType = 7 + ApplicationRoleConnectionMetadataBooleanNotEqual ApplicationRoleConnectionMetadataType = 8 +) + +// ApplicationRoleConnectionMetadata stores application role connection metadata. +type ApplicationRoleConnectionMetadata struct { + Type ApplicationRoleConnectionMetadataType `json:"type"` + Key string `json:"key"` + Name string `json:"name"` + NameLocalizations map[Locale]string `json:"name_localizations"` + Description string `json:"description"` + DescriptionLocalizations map[Locale]string `json:"description_localizations"` +} + +// ApplicationRoleConnection represents the role connection that an application has attached to a user. +type ApplicationRoleConnection struct { + PlatformName string `json:"platform_name"` + PlatformUsername string `json:"platform_username"` + Metadata map[string]string `json:"metadata"` +} + // UserConnection is a Connection returned from the UserConnections endpoint type UserConnection struct { ID string `json:"id"` @@ -254,6 +285,42 @@ const ( ChannelTypeGuildPublicThread ChannelType = 11 ChannelTypeGuildPrivateThread ChannelType = 12 ChannelTypeGuildStageVoice ChannelType = 13 + ChannelTypeGuildForum ChannelType = 15 +) + +// ChannelFlags represent flags of a channel/thread. +type ChannelFlags int + +// Block containing known ChannelFlags values. +const ( + // ChannelFlagPinned indicates whether the thread is pinned in the forum channel. + // NOTE: forum threads only. + ChannelFlagPinned ChannelFlags = 1 << 1 + // ChannelFlagRequireTag indicates whether a tag is required to be specified when creating a thread. + // NOTE: forum channels only. + ChannelFlagRequireTag ChannelFlags = 1 << 4 +) + +// ForumSortOrderType represents sort order of a forum channel. +type ForumSortOrderType int + +const ( + // ForumSortOrderLatestActivity sorts posts by activity. + ForumSortOrderLatestActivity ForumSortOrderType = 0 + // ForumSortOrderCreationDate sorts posts by creation time (from most recent to oldest). + ForumSortOrderCreationDate ForumSortOrderType = 1 +) + +// ForumLayout represents layout of a forum channel. +type ForumLayout int + +const ( + // ForumLayoutNotSet represents no default layout. + ForumLayoutNotSet ForumLayout = 0 + // ForumLayoutListView displays forum posts as a list. + ForumLayoutListView ForumLayout = 1 + // ForumLayoutGalleryView displays forum posts as a collection of tiles. + ForumLayoutGalleryView ForumLayout = 2 ) // A Channel holds all data related to an individual Discord channel. @@ -332,6 +399,30 @@ type Channel struct { // All thread members. State channels only. Members []*ThreadMember `json:"-"` + + // Channel flags. + Flags ChannelFlags `json:"flags"` + + // The set of tags that can be used in a forum channel. + AvailableTags []ForumTag `json:"available_tags"` + + // The IDs of the set of tags that have been applied to a thread in a forum channel. + AppliedTags []string `json:"applied_tags"` + + // Emoji to use as the default reaction to a forum post. + DefaultReactionEmoji ForumDefaultReaction `json:"default_reaction_emoji"` + + // The initial RateLimitPerUser to set on newly created threads in a channel. + // This field is copied to the thread at creation time and does not live update. + DefaultThreadRateLimitPerUser int `json:"default_thread_rate_limit_per_user"` + + // The default sort order type used to order posts in forum channels. + // Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin. + DefaultSortOrder *ForumSortOrderType `json:"default_sort_order"` + + // The default forum layout view used to display posts in forum channels. + // Defaults to ForumLayoutNotSet, which indicates a layout view has not been set by a channel admin. + DefaultForumLayout ForumLayout `json:"default_forum_layout"` } // Mention returns a string which mentions the channel @@ -346,15 +437,17 @@ func (c *Channel) IsThread() bool { // A ChannelEdit holds Channel Field data for a channel edit. type ChannelEdit struct { - Name string `json:"name,omitempty"` - Topic string `json:"topic,omitempty"` - NSFW *bool `json:"nsfw,omitempty"` - Position int `json:"position"` - Bitrate int `json:"bitrate,omitempty"` - UserLimit int `json:"user_limit,omitempty"` - PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"` - ParentID string `json:"parent_id,omitempty"` - RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"` + Name string `json:"name,omitempty"` + Topic string `json:"topic,omitempty"` + NSFW *bool `json:"nsfw,omitempty"` + Position int `json:"position"` + Bitrate int `json:"bitrate,omitempty"` + UserLimit int `json:"user_limit,omitempty"` + PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"` + ParentID string `json:"parent_id,omitempty"` + RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"` + Flags *ChannelFlags `json:"flags,omitempty"` + DefaultThreadRateLimitPerUser *int `json:"default_thread_rate_limit_per_user,omitempty"` // NOTE: threads only @@ -362,6 +455,16 @@ type ChannelEdit struct { AutoArchiveDuration int `json:"auto_archive_duration,omitempty"` Locked *bool `json:"locked,omitempty"` Invitable *bool `json:"invitable,omitempty"` + + // NOTE: forum channels only + + AvailableTags *[]ForumTag `json:"available_tags,omitempty"` + DefaultReactionEmoji *ForumDefaultReaction `json:"default_reaction_emoji,omitempty"` + DefaultSortOrder *ForumSortOrderType `json:"default_sort_order,omitempty"` // TODO: null + DefaultForumLayout *ForumLayout `json:"default_forum_layout,omitempty"` + + // NOTE: forum threads only + AppliedTags *[]string `json:"applied_tags,omitempty"` } // A ChannelFollow holds data returned after following a news channel @@ -395,6 +498,9 @@ type ThreadStart struct { Type ChannelType `json:"type,omitempty"` Invitable bool `json:"invitable"` RateLimitPerUser int `json:"rate_limit_per_user,omitempty"` + + // NOTE: forum threads only + AppliedTags []string `json:"applied_tags,omitempty"` } // ThreadMetadata contains a number of thread-specific channel fields that are not needed by other channel types. @@ -421,7 +527,7 @@ type ThreadMember struct { // The time the current user last joined the thread JoinTimestamp time.Time `json:"join_timestamp"` // Any user-thread settings, currently only used for notifications - Flags int + Flags int `json:"flags"` } // ThreadsList represents a list of threads alongisde with thread member objects for the current user. @@ -438,6 +544,24 @@ type AddedThreadMember struct { Presence *Presence `json:"presence"` } +// ForumDefaultReaction specifies emoji to use as the default reaction to a forum post. +// NOTE: Exactly one of EmojiID and EmojiName must be set. +type ForumDefaultReaction struct { + // The id of a guild's custom emoji. + EmojiID string `json:"emoji_id,omitempty"` + // The unicode character of the emoji. + EmojiName string `json:"emoji_name,omitempty"` +} + +// ForumTag represents a tag that is able to be applied to a thread in a forum channel. +type ForumTag struct { + ID string `json:"id,omitempty"` + Name string `json:"name"` + Moderated bool `json:"moderated"` + EmojiID string `json:"emoji_id,omitempty"` + EmojiName string `json:"emoji_name,omitempty"` +} + // Emoji struct holds data related to Emoji's type Emoji struct { ID string `json:"id"` @@ -452,7 +576,7 @@ type Emoji struct { // EmojiRegex is the regex used to find and identify emojis in messages var ( - EmojiRegex = regexp.MustCompile(`<(a|):[A-z0-9_~]+:[0-9]{18}>`) + EmojiRegex = regexp.MustCompile(`<(a|):[A-z0-9_~]+:[0-9]{18,20}>`) ) // MessageFormat returns a correctly formatted Emoji for use in Message content and embeds @@ -498,6 +622,7 @@ const ( StickerFormatTypePNG StickerFormat = 1 StickerFormatTypeAPNG StickerFormat = 2 StickerFormatTypeLottie StickerFormat = 3 + StickerFormatTypeGIF StickerFormat = 4 ) // StickerType is the type of sticker. @@ -792,16 +917,11 @@ type GuildPreview struct { } // IconURL returns a URL to the guild's icon. -func (g *GuildPreview) IconURL() string { - if g.Icon == "" { - return "" - } - - if strings.HasPrefix(g.Icon, "a_") { - return EndpointGuildIconAnimated(g.ID, g.Icon) - } - - return EndpointGuildIcon(g.ID, g.Icon) +// +// size: The size of the desired icon image as a power of two +// Image size can be any power of two between 16 and 4096. +func (g *GuildPreview) IconURL(size string) string { + return iconURL(g.Icon, EndpointGuildIcon(g.ID, g.Icon), EndpointGuildIconAnimated(g.ID, g.Icon), size) } // GuildScheduledEvent is a representation of a scheduled event in a guild. Only for retrieval of the data. @@ -917,13 +1037,13 @@ type GuildScheduledEventStatus int const ( // GuildScheduledEventStatusScheduled represents the current event is in scheduled state - GuildScheduledEventStatusScheduled = 1 + GuildScheduledEventStatusScheduled GuildScheduledEventStatus = 1 // GuildScheduledEventStatusActive represents the current event is in active state - GuildScheduledEventStatusActive = 2 + GuildScheduledEventStatusActive GuildScheduledEventStatus = 2 // GuildScheduledEventStatusCompleted represents the current event is in completed state - GuildScheduledEventStatusCompleted = 3 + GuildScheduledEventStatusCompleted GuildScheduledEventStatus = 3 // GuildScheduledEventStatusCanceled represents the current event is in canceled state - GuildScheduledEventStatusCanceled = 4 + GuildScheduledEventStatusCanceled GuildScheduledEventStatus = 4 ) // GuildScheduledEventEntityType is the type of entity associated with a guild scheduled event. @@ -932,11 +1052,11 @@ type GuildScheduledEventEntityType int const ( // GuildScheduledEventEntityTypeStageInstance represents a stage channel - GuildScheduledEventEntityTypeStageInstance = 1 + GuildScheduledEventEntityTypeStageInstance GuildScheduledEventEntityType = 1 // GuildScheduledEventEntityTypeVoice represents a voice channel - GuildScheduledEventEntityTypeVoice = 2 + GuildScheduledEventEntityTypeVoice GuildScheduledEventEntityType = 2 // GuildScheduledEventEntityTypeExternal represents an external event - GuildScheduledEventEntityTypeExternal = 3 + GuildScheduledEventEntityTypeExternal GuildScheduledEventEntityType = 3 ) // GuildScheduledEventUser is a user subscribed to a scheduled event. @@ -1007,29 +1127,26 @@ type SystemChannelFlag int // Block containing known SystemChannelFlag values const ( - SystemChannelFlagsSuppressJoin SystemChannelFlag = 1 << 0 - SystemChannelFlagsSuppressPremium SystemChannelFlag = 1 << 1 + SystemChannelFlagsSuppressJoinNotifications SystemChannelFlag = 1 << 0 + SystemChannelFlagsSuppressPremium SystemChannelFlag = 1 << 1 + SystemChannelFlagsSuppressGuildReminderNotifications SystemChannelFlag = 1 << 2 + SystemChannelFlagsSuppressJoinNotificationReplies SystemChannelFlag = 1 << 3 ) // IconURL returns a URL to the guild's icon. -func (g *Guild) IconURL() string { - if g.Icon == "" { - return "" - } - - if strings.HasPrefix(g.Icon, "a_") { - return EndpointGuildIconAnimated(g.ID, g.Icon) - } - - return EndpointGuildIcon(g.ID, g.Icon) +// +// size: The size of the desired icon image as a power of two +// Image size can be any power of two between 16 and 4096. +func (g *Guild) IconURL(size string) string { + return iconURL(g.Icon, EndpointGuildIcon(g.ID, g.Icon), EndpointGuildIconAnimated(g.ID, g.Icon), size) } // BannerURL returns a URL to the guild's banner. -func (g *Guild) BannerURL() string { - if g.Banner == "" { - return "" - } - return EndpointGuildBanner(g.ID, g.Banner) +// +// size: The size of the desired banner image as a power of two +// Image size can be any power of two between 16 and 4096. +func (g *Guild) BannerURL(size string) string { + return bannerURL(g.Banner, EndpointGuildBanner(g.ID, g.Banner), EndpointGuildBannerAnimated(g.ID, g.Banner), size) } // A UserGuild holds a brief version of a Guild @@ -1076,12 +1193,22 @@ type GuildParams struct { Region string `json:"region,omitempty"` VerificationLevel *VerificationLevel `json:"verification_level,omitempty"` DefaultMessageNotifications int `json:"default_message_notifications,omitempty"` // TODO: Separate type? + ExplicitContentFilter int `json:"explicit_content_filter,omitempty"` AfkChannelID string `json:"afk_channel_id,omitempty"` AfkTimeout int `json:"afk_timeout,omitempty"` Icon string `json:"icon,omitempty"` OwnerID string `json:"owner_id,omitempty"` Splash string `json:"splash,omitempty"` + DiscoverySplash string `json:"discovery_splash,omitempty"` Banner string `json:"banner,omitempty"` + SystemChannelID string `json:"system_channel_id,omitempty"` + SystemChannelFlags SystemChannelFlag `json:"system_channel_flags,omitempty"` + RulesChannelID string `json:"rules_channel_id,omitempty"` + PublicUpdatesChannelID string `json:"public_updates_channel_id,omitempty"` + PreferredLocale Locale `json:"preferred_locale,omitempty"` + Features []GuildFeature `json:"features,omitempty"` + Description string `json:"description,omitempty"` + PremiumProgressBarEnabled *bool `json:"premium_progress_bar_enabled,omitempty"` } // A Role stores information about Discord guild member roles. @@ -1167,10 +1294,11 @@ type VoiceState struct { // A Presence stores the online, offline, or idle and game status of Guild members. type Presence struct { - User *User `json:"user"` - Status Status `json:"status"` - Activities []*Activity `json:"activities"` - Since *int `json:"since"` + User *User `json:"user"` + Status Status `json:"status"` + Activities []*Activity `json:"activities"` + Since *int `json:"since"` + ClientStatus ClientStatus `json:"client_status"` } // A TimeStamps struct contains start and end times used in the rich presence "playing .." Game @@ -1249,9 +1377,10 @@ func (m *Member) Mention() string { } // AvatarURL returns the URL of the member's avatar -// size: The size of the user's avatar as a power of two -// if size is an empty string, no size parameter will -// be added to the URL. +// +// size: The size of the user's avatar as a power of two +// if size is an empty string, no size parameter will +// be added to the URL. func (m *Member) AvatarURL(size string) string { if m.Avatar == "" { return m.User.AvatarURL(size) @@ -1262,6 +1391,13 @@ func (m *Member) AvatarURL(size string) string { } +// ClientStatus stores the online, offline, idle, or dnd status of each device of a Guild member. +type ClientStatus struct { + Desktop Status `json:"desktop"` + Mobile Status `json:"mobile"` + Web Status `json:"web"` +} + // Status type definition type Status string @@ -1371,9 +1507,21 @@ type AutoModerationTriggerMetadata struct { // Substrings which will be searched for in content. // NOTE: should be only used with keyword trigger type. KeywordFilter []string `json:"keyword_filter,omitempty"` + // Regular expression patterns which will be matched against content (maximum of 10). + // NOTE: should be only used with keyword trigger type. + RegexPatterns []string `json:"regex_patterns,omitempty"` + // Internally pre-defined wordsets which will be searched for in content. // NOTE: should be only used with keyword preset trigger type. Presets []AutoModerationKeywordPreset `json:"presets,omitempty"` + + // Substrings which should not trigger the rule. + // NOTE: should be only used with keyword or keyword preset trigger type. + AllowList *[]string `json:"allow_list,omitempty"` + + // Total number of unique role and user mentions allowed per message. + // NOTE: should be only used with mention spam trigger type. + MentionTotalLimit int `json:"mention_total_limit,omitempty"` } // AutoModerationActionType represents an action which will execute whenever a rule is triggered. @@ -2074,6 +2222,7 @@ const ( ErrCodeUnknownGuildWelcomeScreen = 10069 ErrCodeUnknownGuildScheduledEvent = 10070 ErrCodeUnknownGuildScheduledEventUser = 10071 + ErrUnknownTag = 10087 ErrCodeBotsCannotUseEndpoint = 20001 ErrCodeOnlyBotsCanUseEndpoint = 20002 @@ -2087,28 +2236,30 @@ const ( ErrCodeStageTopicContainsNotAllowedWordsForPublicStages = 20031 ErrCodeGuildPremiumSubscriptionLevelTooLow = 20035 - ErrCodeMaximumGuildsReached = 30001 - ErrCodeMaximumPinsReached = 30003 - ErrCodeMaximumNumberOfRecipientsReached = 30004 - ErrCodeMaximumGuildRolesReached = 30005 - ErrCodeMaximumNumberOfWebhooksReached = 30007 - ErrCodeMaximumNumberOfEmojisReached = 30008 - ErrCodeTooManyReactions = 30010 - ErrCodeMaximumNumberOfGuildChannelsReached = 30013 - ErrCodeMaximumNumberOfAttachmentsInAMessageReached = 30015 - ErrCodeMaximumNumberOfInvitesReached = 30016 - ErrCodeMaximumNumberOfAnimatedEmojisReached = 30018 - ErrCodeMaximumNumberOfServerMembersReached = 30019 - ErrCodeMaximumNumberOfGuildDiscoverySubcategoriesReached = 30030 - ErrCodeGuildAlreadyHasATemplate = 30031 - ErrCodeMaximumNumberOfThreadParticipantsReached = 30033 - ErrCodeMaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035 - ErrCodeMaximumNumberOfBansFetchesHasBeenReached = 30037 - ErrCodeMaximumNumberOfUncompletedGuildScheduledEventsReached = 30038 - ErrCodeMaximumNumberOfStickersReached = 30039 - ErrCodeMaximumNumberOfPruneRequestsHasBeenReached = 30040 - ErrCodeMaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042 - ErrCodeMaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046 + ErrCodeMaximumGuildsReached = 30001 + ErrCodeMaximumPinsReached = 30003 + ErrCodeMaximumNumberOfRecipientsReached = 30004 + ErrCodeMaximumGuildRolesReached = 30005 + ErrCodeMaximumNumberOfWebhooksReached = 30007 + ErrCodeMaximumNumberOfEmojisReached = 30008 + ErrCodeTooManyReactions = 30010 + ErrCodeMaximumNumberOfGuildChannelsReached = 30013 + ErrCodeMaximumNumberOfAttachmentsInAMessageReached = 30015 + ErrCodeMaximumNumberOfInvitesReached = 30016 + ErrCodeMaximumNumberOfAnimatedEmojisReached = 30018 + ErrCodeMaximumNumberOfServerMembersReached = 30019 + ErrCodeMaximumNumberOfGuildDiscoverySubcategoriesReached = 30030 + ErrCodeGuildAlreadyHasATemplate = 30031 + ErrCodeMaximumNumberOfThreadParticipantsReached = 30033 + ErrCodeMaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035 + ErrCodeMaximumNumberOfBansFetchesHasBeenReached = 30037 + ErrCodeMaximumNumberOfUncompletedGuildScheduledEventsReached = 30038 + ErrCodeMaximumNumberOfStickersReached = 30039 + ErrCodeMaximumNumberOfPruneRequestsHasBeenReached = 30040 + ErrCodeMaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042 + ErrCodeMaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046 + ErrCodeMaximumNumberOfPinnedThreadsInForumChannelHasBeenReached = 30047 + ErrCodeMaximumNumberOfTagsInForumChannelHasBeenReached = 30048 ErrCodeUnauthorized = 40001 ErrCodeActionRequiredVerifiedAccount = 40002 @@ -2121,6 +2272,7 @@ const ( ErrCodeMessageAlreadyCrossposted = 40033 ErrCodeAnApplicationWithThatNameAlreadyExists = 40041 ErrCodeInteractionHasAlreadyBeenAcknowledged = 40060 + ErrCodeTagNamesMustBeUnique = 40061 ErrCodeMissingAccess = 50001 ErrCodeInvalidAccountType = 50002 |