2020-01-19 21:54:16 +00:00
|
|
|
package gateway
|
|
|
|
|
2020-08-15 01:13:35 +00:00
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
2020-10-28 22:39:59 +00:00
|
|
|
"github.com/diamondburned/arikawa/v2/discord"
|
2020-08-15 01:13:35 +00:00
|
|
|
)
|
2020-01-19 21:54:16 +00:00
|
|
|
|
|
|
|
type ReadyEvent struct {
|
|
|
|
Version int `json:"version"`
|
|
|
|
|
|
|
|
User discord.User `json:"user"`
|
|
|
|
SessionID string `json:"session_id"`
|
|
|
|
|
2020-03-01 02:13:58 +00:00
|
|
|
PrivateChannels []discord.Channel `json:"private_channels"`
|
|
|
|
Guilds []GuildCreateEvent `json:"guilds"`
|
2020-01-19 21:54:16 +00:00
|
|
|
|
|
|
|
Shard *Shard `json:"shard"`
|
|
|
|
|
|
|
|
// Undocumented fields
|
2020-02-25 05:50:13 +00:00
|
|
|
Settings *UserSettings `json:"user_settings,omitempty"`
|
|
|
|
UserGuildSettings []UserGuildSettings `json:"user_guild_settings,omitempty"`
|
|
|
|
|
|
|
|
ReadState []ReadState `json:"read_state,omitempty"`
|
|
|
|
Presences []discord.Presence `json:"presences,omitempty"`
|
|
|
|
|
2020-07-21 20:27:59 +00:00
|
|
|
Relationships []discord.Relationship `json:"relationships,omitempty"`
|
|
|
|
Notes map[discord.UserID]string `json:"notes,omitempty"`
|
2020-01-19 21:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type UserSettings struct {
|
|
|
|
ShowCurrentGame bool `json:"show_current_game"`
|
|
|
|
DefaultGuildsRestricted bool `json:"default_guilds_restricted"`
|
|
|
|
InlineAttachmentMedia bool `json:"inline_attachment_media"`
|
|
|
|
InlineEmbedMedia bool `json:"inline_embed_media"`
|
|
|
|
GIFAutoPlay bool `json:"gif_auto_play"`
|
|
|
|
RenderEmbeds bool `json:"render_embeds"`
|
|
|
|
RenderReactions bool `json:"render_reactions"`
|
|
|
|
AnimateEmoji bool `json:"animate_emoji"`
|
|
|
|
EnableTTSCommand bool `json:"enable_tts_command"`
|
|
|
|
MessageDisplayCompact bool `json:"message_display_compact"`
|
|
|
|
ConvertEmoticons bool `json:"convert_emoticons"`
|
|
|
|
ExplicitContentFilter uint8 `json:"explicit_content_filter"` // ???
|
|
|
|
DisableGamesTab bool `json:"disable_games_tab"`
|
|
|
|
DeveloperMode bool `json:"developer_mode"`
|
|
|
|
DetectPlatformAccounts bool `json:"detect_platform_accounts"`
|
|
|
|
StreamNotification bool `json:"stream_notification_enabled"`
|
2020-07-29 23:29:01 +00:00
|
|
|
AccessibilityDetection bool `json:"allow_accessibility_detection"`
|
2020-01-19 21:54:16 +00:00
|
|
|
ContactSync bool `json:"contact_sync_enabled"`
|
|
|
|
NativePhoneIntegration bool `json:"native_phone_integration_enabled"`
|
|
|
|
|
|
|
|
Locale string `json:"locale"`
|
|
|
|
Theme string `json:"theme"`
|
|
|
|
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildPositions []discord.GuildID `json:"guild_positions"`
|
|
|
|
GuildFolders []GuildFolder `json:"guild_folders"`
|
|
|
|
RestrictedGuilds []discord.GuildID `json:"restricted_guilds"`
|
2020-01-19 21:54:16 +00:00
|
|
|
|
|
|
|
FriendSourceFlags struct {
|
|
|
|
All bool `json:"all"`
|
|
|
|
MutualGuilds bool `json:"mutual_guilds"`
|
|
|
|
MutualFriends bool `json:"mutual_friends"`
|
|
|
|
} `json:"friend_source_flags"`
|
|
|
|
|
|
|
|
Status discord.Status `json:"status"`
|
|
|
|
CustomStatus struct {
|
|
|
|
Text string `json:"text"`
|
|
|
|
ExpiresAt discord.Timestamp `json:"expires_at,omitempty"`
|
2020-07-21 20:27:59 +00:00
|
|
|
EmojiID discord.EmojiID `json:"emoji_id,string"`
|
2020-01-19 21:54:16 +00:00
|
|
|
EmojiName string `json:"emoji_name"`
|
|
|
|
} `json:"custom_status"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// A UserGuildSettings stores data for a users guild settings.
|
|
|
|
type UserGuildSettings struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
2020-01-19 21:54:16 +00:00
|
|
|
|
2020-07-29 23:29:01 +00:00
|
|
|
SuppressEveryone bool `json:"suppress_everyone"`
|
|
|
|
SuppressRoles bool `json:"suppress_roles"`
|
|
|
|
Muted bool `json:"muted"`
|
|
|
|
MobilePush bool `json:"mobile_push"`
|
2020-03-26 23:28:43 +00:00
|
|
|
|
2020-03-27 00:03:19 +00:00
|
|
|
MessageNotifications UserNotification `json:"message_notifications"`
|
2020-03-26 23:28:43 +00:00
|
|
|
ChannelOverrides []SettingsChannelOverride `json:"channel_overrides"`
|
2020-01-19 21:54:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-27 00:03:19 +00:00
|
|
|
// UserNotification is the notification setting for a channel or guild.
|
|
|
|
type UserNotification uint8
|
2020-03-26 23:28:43 +00:00
|
|
|
|
|
|
|
const (
|
2020-03-27 00:03:19 +00:00
|
|
|
AllNotifications UserNotification = iota
|
2020-03-26 23:28:43 +00:00
|
|
|
OnlyMentions
|
2020-03-27 02:11:25 +00:00
|
|
|
NoNotifications
|
2020-03-26 23:28:43 +00:00
|
|
|
GuildDefaults
|
|
|
|
)
|
|
|
|
|
2020-02-25 05:50:13 +00:00
|
|
|
type ReadState struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID discord.ChannelID `json:"id"`
|
|
|
|
LastMessageID discord.MessageID `json:"last_message_id"`
|
2020-02-25 05:50:13 +00:00
|
|
|
MentionCount int `json:"mention_count"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// A UserGuildSettingsChannelOverride stores data for a channel override for a
|
|
|
|
// users guild settings.
|
|
|
|
type SettingsChannelOverride struct {
|
2020-03-27 00:04:14 +00:00
|
|
|
Muted bool `json:"muted"`
|
2020-02-25 05:50:13 +00:00
|
|
|
|
2020-03-27 00:04:14 +00:00
|
|
|
MessageNotifications UserNotification `json:"message_notifications"`
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
2020-02-25 05:50:13 +00:00
|
|
|
}
|
|
|
|
|
2020-01-19 21:54:16 +00:00
|
|
|
// GuildFolder holds a single folder that you see in the left guild panel.
|
|
|
|
type GuildFolder struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
Name string `json:"name"`
|
2020-08-15 01:13:35 +00:00
|
|
|
ID GuildFolderID `json:"id"`
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildIDs []discord.GuildID `json:"guild_ids"`
|
|
|
|
Color discord.Color `json:"color"`
|
2020-01-19 21:54:16 +00:00
|
|
|
}
|
2020-08-15 01:13:35 +00:00
|
|
|
|
|
|
|
// GuildFolderID is possibly a snowflake. It can also be 0 (null) or a low
|
|
|
|
// number of unknown significance.
|
2020-08-20 04:54:20 +00:00
|
|
|
type GuildFolderID int64
|
2020-08-15 01:13:35 +00:00
|
|
|
|
|
|
|
func (g *GuildFolderID) UnmarshalJSON(b []byte) error {
|
|
|
|
var body = string(b)
|
|
|
|
if body == "null" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
body = strings.Trim(body, `"`)
|
|
|
|
|
2020-08-20 04:54:20 +00:00
|
|
|
u, err := strconv.ParseInt(body, 10, 64)
|
2020-08-15 01:13:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*g = GuildFolderID(u)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g GuildFolderID) MarshalJSON() ([]byte, error) {
|
|
|
|
if g == 0 {
|
|
|
|
return []byte("null"), nil
|
|
|
|
}
|
|
|
|
|
2020-08-20 04:54:20 +00:00
|
|
|
return []byte(strconv.FormatInt(int64(g), 10)), nil
|
2020-08-15 01:13:35 +00:00
|
|
|
}
|