1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-28 01:33:10 +00:00

Gateway: Presence to contain user and guild fields

This commit changes the gateway.Presence struct to be similar to commits
prior to the last refactor, that is, the struct would have the User and
GuildID fields. This is done so it's easier to store them.
This commit is contained in:
diamondburned 2020-11-28 22:36:33 -08:00
parent 6ef093eb98
commit a2333996a2
2 changed files with 15 additions and 11 deletions

View file

@ -58,7 +58,7 @@ type (
VoiceStates []discord.VoiceState `json:"voice_states,omitempty"`
Members []discord.Member `json:"members,omitempty"`
Channels []discord.Channel `json:"channels,omitempty"`
Presences []Presence `json:"presences,omitempty"`
Presences []Presence `json:"presences,omitempty"`
}
GuildUpdateEvent struct {
discord.Guild
@ -115,7 +115,7 @@ type (
// Only filled if requested
Presences []Presence `json:"presences,omitempty"`
Nonce string `json:"nonce,omitempty"`
Nonce string `json:"nonce,omitempty"`
}
// GuildMemberListUpdate is an undocumented event. It's received when the
@ -158,7 +158,7 @@ type (
Group *GuildMemberListGroup `json:"group,omitempty"`
Member *struct {
discord.Member
HoistedRole string `json:"hoisted_role"`
HoistedRole string `json:"hoisted_role"`
Presence Presence `json:"presence"`
} `json:"member,omitempty"`
}
@ -279,6 +279,11 @@ type (
// easily embedded. It does not contain any ID to identify who it belongs
// to. For more information, refer to the PresenceUpdateEvent struct.
Presence struct {
// User is the user presence is being updated for. Only the ID field is
// guaranteed to be valid per Discord documentation.
User discord.User `json:"user"`
// GuildID is the id of the guild
GuildID discord.GuildID `json:"guild_id"`
// Status is either "idle", "dnd", "online", or "offline".
Status Status `json:"status"`
// Activities are the user's current activities.
@ -303,15 +308,10 @@ type (
}
// PresenceUpdateEvent represents the structure of the Presence Update Event
// object. This event may be sent on itself or within other events.
// object.
//
// https://discord.com/developers/docs/topics/gateway#presence-update-presence-update-event-fields
PresenceUpdateEvent struct {
// User is the user presence is being updated for.
User discord.User `json:"user"`
// GuildID is the id of the guild
GuildID discord.GuildID `json:"guild_id"`
// Presence contains the rest of the update struct.
Presence
}

View file

@ -232,8 +232,12 @@ type (
SupplementalPresence struct {
UserID discord.UserID `json:"user_id"`
// Presence contains the rest of this struct.
Presence
// Status is either "idle", "dnd", "online", or "offline".
Status Status `json:"status"`
// Activities are the user's current activities.
Activities []discord.Activity `json:"activities"`
// ClientStaus is the user's platform-dependent status.
ClientStatus ClientStatus `json:"client_status"`
// LastModified is only present in Friends.
LastModified discord.UnixMsTimestamp `json:"last_modified,omitempty"`