github.com/diamondburned/arikawa@v1.3.14/gateway/ready.go (about) 1 package gateway 2 3 import ( 4 "strconv" 5 "strings" 6 7 "github.com/diamondburned/arikawa/discord" 8 ) 9 10 type ReadyEvent struct { 11 Version int `json:"version"` 12 13 User discord.User `json:"user"` 14 SessionID string `json:"session_id"` 15 16 PrivateChannels []discord.Channel `json:"private_channels"` 17 Guilds []GuildCreateEvent `json:"guilds"` 18 19 Shard *Shard `json:"shard"` 20 21 // Undocumented fields 22 Settings *UserSettings `json:"user_settings,omitempty"` 23 UserGuildSettings []UserGuildSettings `json:"user_guild_settings,omitempty"` 24 25 ReadState []ReadState `json:"read_state,omitempty"` 26 Presences []discord.Presence `json:"presences,omitempty"` 27 28 Relationships []discord.Relationship `json:"relationships,omitempty"` 29 Notes map[discord.UserID]string `json:"notes,omitempty"` 30 } 31 32 type UserSettings struct { 33 ShowCurrentGame bool `json:"show_current_game"` 34 DefaultGuildsRestricted bool `json:"default_guilds_restricted"` 35 InlineAttachmentMedia bool `json:"inline_attachment_media"` 36 InlineEmbedMedia bool `json:"inline_embed_media"` 37 GIFAutoPlay bool `json:"gif_auto_play"` 38 RenderEmbeds bool `json:"render_embeds"` 39 RenderReactions bool `json:"render_reactions"` 40 AnimateEmoji bool `json:"animate_emoji"` 41 EnableTTSCommand bool `json:"enable_tts_command"` 42 MessageDisplayCompact bool `json:"message_display_compact"` 43 ConvertEmoticons bool `json:"convert_emoticons"` 44 ExplicitContentFilter uint8 `json:"explicit_content_filter"` // ??? 45 DisableGamesTab bool `json:"disable_games_tab"` 46 DeveloperMode bool `json:"developer_mode"` 47 DetectPlatformAccounts bool `json:"detect_platform_accounts"` 48 StreamNotification bool `json:"stream_notification_enabled"` 49 AccessibilityDetection bool `json:"allow_accessibility_detection"` 50 ContactSync bool `json:"contact_sync_enabled"` 51 NativePhoneIntegration bool `json:"native_phone_integration_enabled"` 52 53 Locale string `json:"locale"` 54 Theme string `json:"theme"` 55 56 GuildPositions []discord.GuildID `json:"guild_positions"` 57 GuildFolders []GuildFolder `json:"guild_folders"` 58 RestrictedGuilds []discord.GuildID `json:"restricted_guilds"` 59 60 FriendSourceFlags struct { 61 All bool `json:"all"` 62 MutualGuilds bool `json:"mutual_guilds"` 63 MutualFriends bool `json:"mutual_friends"` 64 } `json:"friend_source_flags"` 65 66 Status discord.Status `json:"status"` 67 CustomStatus struct { 68 Text string `json:"text"` 69 ExpiresAt discord.Timestamp `json:"expires_at,omitempty"` 70 EmojiID discord.EmojiID `json:"emoji_id,string"` 71 EmojiName string `json:"emoji_name"` 72 } `json:"custom_status"` 73 } 74 75 // A UserGuildSettings stores data for a users guild settings. 76 type UserGuildSettings struct { 77 GuildID discord.GuildID `json:"guild_id"` 78 79 SuppressEveryone bool `json:"suppress_everyone"` 80 SuppressRoles bool `json:"suppress_roles"` 81 Muted bool `json:"muted"` 82 MobilePush bool `json:"mobile_push"` 83 84 MessageNotifications UserNotification `json:"message_notifications"` 85 ChannelOverrides []SettingsChannelOverride `json:"channel_overrides"` 86 } 87 88 // UserNotification is the notification setting for a channel or guild. 89 type UserNotification uint8 90 91 const ( 92 AllNotifications UserNotification = iota 93 OnlyMentions 94 NoNotifications 95 GuildDefaults 96 ) 97 98 type ReadState struct { 99 ChannelID discord.ChannelID `json:"id"` 100 LastMessageID discord.MessageID `json:"last_message_id"` 101 MentionCount int `json:"mention_count"` 102 } 103 104 // A UserGuildSettingsChannelOverride stores data for a channel override for a 105 // users guild settings. 106 type SettingsChannelOverride struct { 107 Muted bool `json:"muted"` 108 109 MessageNotifications UserNotification `json:"message_notifications"` 110 ChannelID discord.ChannelID `json:"channel_id"` 111 } 112 113 // GuildFolder holds a single folder that you see in the left guild panel. 114 type GuildFolder struct { 115 Name string `json:"name"` 116 ID GuildFolderID `json:"id"` 117 GuildIDs []discord.GuildID `json:"guild_ids"` 118 Color discord.Color `json:"color"` 119 } 120 121 // GuildFolderID is possibly a snowflake. It can also be 0 (null) or a low 122 // number of unknown significance. 123 type GuildFolderID int64 124 125 func (g *GuildFolderID) UnmarshalJSON(b []byte) error { 126 var body = string(b) 127 if body == "null" { 128 return nil 129 } 130 131 body = strings.Trim(body, `"`) 132 133 u, err := strconv.ParseInt(body, 10, 64) 134 if err != nil { 135 return err 136 } 137 138 *g = GuildFolderID(u) 139 return nil 140 } 141 142 func (g GuildFolderID) MarshalJSON() ([]byte, error) { 143 if g == 0 { 144 return []byte("null"), nil 145 } 146 147 return []byte(strconv.FormatInt(int64(g), 10)), nil 148 }