Skip to content

Commit b2668c6

Browse files
committed
Add new activity fields
discord/discord-api-docs#7674
1 parent 1328ec5 commit b2668c6

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

bot/handlers/presence_update_handler.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,11 @@ func isActivityUpdated(old discord.Activity, new discord.Activity) bool {
120120
compareActivityTimestampsPtr(old.Timestamps, new.Timestamps) ||
121121
compareStringPtr(old.SyncID, new.SyncID) ||
122122
old.ApplicationID != new.ApplicationID ||
123+
compareStatusDisplayTypePtr(old.StatusDisplayType, new.StatusDisplayType) ||
123124
compareStringPtr(old.Details, new.Details) ||
125+
compareStringPtr(old.DetailsURL, new.DetailsURL) ||
124126
compareStringPtr(old.State, new.State) ||
127+
compareStringPtr(old.StateURL, new.StateURL) ||
125128
comparePartialEmojiPtr(old.Emoji, new.Emoji) ||
126129
compareActivityPartyPtr(old.Party, new.Party) ||
127130
compareActivityAssetsPtr(old.Assets, new.Assets) ||
@@ -204,7 +207,7 @@ func compareActivityAssetsPtr(old *discord.ActivityAssets, new *discord.Activity
204207
if old == nil || new == nil {
205208
return true
206209
}
207-
return old.LargeText != new.LargeText || old.LargeImage != new.LargeImage || old.SmallText != new.SmallText || old.SmallImage != new.SmallImage
210+
return old.LargeText != new.LargeText || old.LargeImage != new.LargeImage || old.LargeURL != new.LargeURL || old.SmallText != new.SmallText || old.SmallImage != new.SmallImage || old.SmallURL != new.SmallURL
208211
}
209212

210213
func compareActivitySecretsPtr(old *discord.ActivitySecrets, new *discord.ActivitySecrets) bool {
@@ -216,3 +219,13 @@ func compareActivitySecretsPtr(old *discord.ActivitySecrets, new *discord.Activi
216219
}
217220
return old.Join != new.Join || old.Spectate != new.Spectate || old.Match != new.Match
218221
}
222+
223+
func compareStatusDisplayTypePtr(old *discord.ActivityStatusDisplayType, new *discord.ActivityStatusDisplayType) bool {
224+
if old == nil && new == nil {
225+
return false
226+
}
227+
if old == nil || new == nil {
228+
return true
229+
}
230+
return *old != *new
231+
}

discord/activity.go

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,26 @@ const (
2424

2525
// Activity represents the fields of a user's presence
2626
type Activity struct {
27-
ID string `json:"id"`
28-
Name string `json:"name"`
29-
Type ActivityType `json:"type"`
30-
URL *string `json:"url,omitempty"`
31-
CreatedAt time.Time `json:"created_at"`
32-
Timestamps *ActivityTimestamps `json:"timestamps,omitempty"`
33-
SyncID *string `json:"sync_id,omitempty"`
34-
ApplicationID snowflake.ID `json:"application_id,omitempty"`
35-
Details *string `json:"details,omitempty"`
36-
State *string `json:"state,omitempty"`
37-
Emoji *PartialEmoji `json:"emoji,omitempty"`
38-
Party *ActivityParty `json:"party,omitempty"`
39-
Assets *ActivityAssets `json:"assets,omitempty"`
40-
Secrets *ActivitySecrets `json:"secrets,omitempty"`
41-
Instance *bool `json:"instance,omitempty"`
42-
Flags ActivityFlags `json:"flags,omitempty"`
43-
Buttons []string `json:"buttons,omitempty"`
27+
ID string `json:"id"`
28+
Name string `json:"name"`
29+
Type ActivityType `json:"type"`
30+
URL *string `json:"url,omitempty"`
31+
CreatedAt time.Time `json:"created_at"`
32+
Timestamps *ActivityTimestamps `json:"timestamps,omitempty"`
33+
SyncID *string `json:"sync_id,omitempty"`
34+
ApplicationID snowflake.ID `json:"application_id,omitempty"`
35+
StatusDisplayType *ActivityStatusDisplayType `json:"status_display_type,omitempty"`
36+
Details *string `json:"details,omitempty"`
37+
DetailsURL *string `json:"details_url,omitempty"`
38+
State *string `json:"state,omitempty"`
39+
StateURL *string `json:"state_url,omitempty"`
40+
Emoji *PartialEmoji `json:"emoji,omitempty"`
41+
Party *ActivityParty `json:"party,omitempty"`
42+
Assets *ActivityAssets `json:"assets,omitempty"`
43+
Secrets *ActivitySecrets `json:"secrets,omitempty"`
44+
Instance *bool `json:"instance,omitempty"`
45+
Flags ActivityFlags `json:"flags,omitempty"`
46+
Buttons []string `json:"buttons,omitempty"`
4447
}
4548

4649
func (a *Activity) UnmarshalJSON(data []byte) error {
@@ -149,8 +152,10 @@ type ActivityParty struct {
149152
type ActivityAssets struct {
150153
LargeImage string `json:"large_image,omitempty"`
151154
LargeText string `json:"large_text,omitempty"`
155+
LargeURL string `json:"large_url,omitempty"`
152156
SmallImage string `json:"small_image,omitempty"`
153157
SmallText string `json:"small_text,omitempty"`
158+
SmallURL string `json:"small_url,omitempty"`
154159
}
155160

156161
// ActivitySecrets contain secrets for Rich Presence joining and spectating
@@ -159,3 +164,11 @@ type ActivitySecrets struct {
159164
Spectate string `json:"spectate,omitempty"`
160165
Match string `json:"match,omitempty"`
161166
}
167+
168+
type ActivityStatusDisplayType int
169+
170+
const (
171+
ActivityStatusDisplayTypeName ActivityStatusDisplayType = iota
172+
ActivityStatusDisplayTypeState
173+
ActivityStatusDisplayTypeDetails
174+
)

0 commit comments

Comments
 (0)