@@ -122,6 +122,105 @@ const (
122
122
AuditLogHomeSettingsUpdate
123
123
)
124
124
125
+ // AuditLogChangeKey is a string representing a key in the audit log change object.
126
+ type AuditLogChangeKey string
127
+
128
+ const (
129
+ AuditLogChangeKeyAFKChannelID AuditLogChangeKey = "afk_channel_id"
130
+ AuditLogChangeKeyAFKTimeout AuditLogChangeKey = "afk_timeout"
131
+ // AuditLogChangeKeyAllow is sent when a role's permission overwrites changed (stringy int)
132
+ AuditLogChangeKeyAllow AuditLogChangeKey = "allow"
133
+ AuditLogChangeKeyApplicationID AuditLogChangeKey = "application_id"
134
+ // AuditLogChangeKeyArchived is sent when a channel thread is archived/unarchived (bool)
135
+ AuditLogChangeKeyArchived AuditLogChangeKey = "archived"
136
+ AuditLogChangeKeyAsset AuditLogChangeKey = "asset"
137
+ // AuditLogChangeKeyAutoArchiveDuration is sent when a thread's auto archive duration is changed (int)
138
+ AuditLogChangeKeyAutoArchiveDuration AuditLogChangeKey = "auto_archive_duration"
139
+ AuditLogChangeKeyAvailable AuditLogChangeKey = "available"
140
+ AuditLogChangeKeyAvatarHash AuditLogChangeKey = "avatar_hash"
141
+ AuditLogChangeKeyBannerHash AuditLogChangeKey = "banner_hash"
142
+ AuditLogChangeKeyBitrate AuditLogChangeKey = "bitrate"
143
+ AuditLogChangeKeyChannelID AuditLogChangeKey = "channel_id"
144
+ AuditLogChangeKeyCode AuditLogChangeKey = "code"
145
+ // AuditLogChangeKeyColor is sent when a role's color is changed (int)
146
+ AuditLogChangeKeyColor AuditLogChangeKey = "color"
147
+ // AuditLogChangeKeyCommunicationDisabledUntil is sent when a user's communication disabled until datetime is changed (stringy ISO8601 datetime)
148
+ AuditLogChangeKeyCommunicationDisabledUntil AuditLogChangeKey = "communication_disabled_until"
149
+ // AuditLogChangeKeyDeaf is sent when a user is set to be server deafened/undeafened (bool)
150
+ AuditLogChangeKeyDeaf AuditLogChangeKey = "deaf"
151
+ AuditLogChangeKeyDefaultAutoArchiveDuration AuditLogChangeKey = "default_auto_archive_duration"
152
+ AuditLogChangeKeyDefaultMessageNotifications AuditLogChangeKey = "default_message_notifications"
153
+ // AuditLogChangeKeyDeny is sent when a role's permission overwrites changed (stringed int)
154
+ AuditLogChangeKeyDeny AuditLogChangeKey = "deny"
155
+ AuditLogChangeKeyDescription AuditLogChangeKey = "description"
156
+ AuditLogChangeKeyDiscoverySplashHash AuditLogChangeKey = "discovery_splash_hash"
157
+ AuditLogChangeKeyEnableEmoticons AuditLogChangeKey = "enable_emoticons"
158
+ AuditLogChangeKeyEntityType AuditLogChangeKey = "entity_type"
159
+ AuditLogChangeKeyExpireBehavior AuditLogChangeKey = "expire_behavior"
160
+ AuditLogChangeKeyExpireGracePeriod AuditLogChangeKey = "expire_grace_period"
161
+ AuditLogChangeKeyExplicitContentFilter AuditLogChangeKey = "explicit_content_filter"
162
+ AuditLogChangeKeyFormatType AuditLogChangeKey = "format_type"
163
+ AuditLogChangeKeyGuildID AuditLogChangeKey = "guild_id"
164
+ // AuditLogChangeKeyHoist is sent when a role is set to be displayed separately from online members (bool)
165
+ AuditLogChangeKeyHoist AuditLogChangeKey = "hoist"
166
+ AuditLogChangeKeyIconHash AuditLogChangeKey = "icon_hash"
167
+ AuditLogChangeKeyID AuditLogChangeKey = "id"
168
+ AuditLogChangeKeyInvitable AuditLogChangeKey = "invitable"
169
+ AuditLogChangeKeyInviterID AuditLogChangeKey = "inviter_id"
170
+ AuditLogChangeKeyLocation AuditLogChangeKey = "location"
171
+ // AuditLogChangeKeyLocked is sent when a channel thread is locked/unlocked (bool)
172
+ AuditLogChangeKeyLocked AuditLogChangeKey = "locked"
173
+ AuditLogChangeKeyMaxAge AuditLogChangeKey = "max_age"
174
+ AuditLogChangeKeyMaxUses AuditLogChangeKey = "max_uses"
175
+ // AuditLogChangeKeyMentionable is sent when a role changes its mentionable state (bool)
176
+ AuditLogChangeKeyMentionable AuditLogChangeKey = "mentionable"
177
+ AuditLogChangeKeyMFALevel AuditLogChangeKey = "mfa_level"
178
+ // AuditLogChangeKeyMute is sent when a user is server muted/unmuted (bool)
179
+ AuditLogChangeKeyMute AuditLogChangeKey = "mute"
180
+ AuditLogChangeKeyName AuditLogChangeKey = "name"
181
+ // AuditLogChangeKeyNick is sent when a user's nickname is changed (string)
182
+ AuditLogChangeKeyNick AuditLogChangeKey = "nick"
183
+ AuditLogChangeKeyNSFW AuditLogChangeKey = "nsfw"
184
+ // AuditLogChangeKeyOwnerID is sent when owner id of a guild changed (snowflake.ID)
185
+ AuditLogChangeKeyOwnerID AuditLogChangeKey = "owner_id"
186
+ // AuditLogChangeKeyPermissionOverwrites is sent when a role's permission overwrites changed (string)
187
+ AuditLogChangeKeyPermissionOverwrites AuditLogChangeKey = "permission_overwrites"
188
+ // AuditLogChangeKeyPermissions is sent when a role's permissions changed (string)
189
+ AuditLogChangeKeyPermissions AuditLogChangeKey = "permissions"
190
+ // AuditLogChangeKeyPosition is sent when channel position changed (int)
191
+ AuditLogChangeKeyPosition AuditLogChangeKey = "position"
192
+ AuditLogChangeKeyPreferredLocale AuditLogChangeKey = "preferred_locale"
193
+ AuditLogChangeKeyPrivacyLevel AuditLogChangeKey = "privacy_level"
194
+ AuditLogChangeKeyPruneDeleteDays AuditLogChangeKey = "prune_delete_days"
195
+ AuditLogChangeKeyPublicUpdatesChannelID AuditLogChangeKey = "public_updates_channel_id"
196
+ AuditLogChangeKeyRateLimitPerUser AuditLogChangeKey = "rate_limit_per_user"
197
+ AuditLogChangeKeyRegion AuditLogChangeKey = "region"
198
+ AuditLogChangeKeyRulesChannelID AuditLogChangeKey = "rules_channel_id"
199
+ AuditLogChangeKeySplashHash AuditLogChangeKey = "splash_hash"
200
+ AuditLogChangeKeyStatus AuditLogChangeKey = "status"
201
+ // AuditLogChangeKeySystemChannelID is sent when system channel id of a guild changed (snowflake.ID)
202
+ AuditLogChangeKeySystemChannelID AuditLogChangeKey = "system_channel_id"
203
+ AuditLogChangeKeyTags AuditLogChangeKey = "tags"
204
+ AuditLogChangeKeyTemporary AuditLogChangeKey = "temporary"
205
+ // AuditLogChangeKeyTopic is sent when channel topic changed (string)
206
+ AuditLogChangeKeyTopic AuditLogChangeKey = "topic"
207
+ AuditLogChangeKeyType AuditLogChangeKey = "type"
208
+ AuditLogChangeKeyUnicodeEmoji AuditLogChangeKey = "unicode_emoji"
209
+ // AuditLogChangeKeyUserLimit is sent when user limit of a voice channel changed (int)
210
+ AuditLogChangeKeyUserLimit AuditLogChangeKey = "user_limit"
211
+ AuditLogChangeKeyUses AuditLogChangeKey = "uses"
212
+ AuditLogChangeKeyVanityURLCode AuditLogChangeKey = "vanity_url_code"
213
+ // AuditLogChangeKeyVerificationLevel is sent when verification level of the server changed (int)
214
+ AuditLogChangeKeyVerificationLevel AuditLogChangeKey = "verification_level"
215
+ AuditLogChangeKeyWidgetChannelID AuditLogChangeKey = "widget_channel_id"
216
+ // AuditLogChangeKeyWidgetEnabled is sent when a server widget is enabled/disabled (bool)
217
+ AuditLogChangeKeyWidgetEnabled AuditLogChangeKey = "widget_enabled"
218
+ // AuditLogChangeKeyRoleAdd is sent when roles are added to a user (array of discord.PartialRole JSON)
219
+ AuditLogChangeKeyRoleAdd AuditLogChangeKey = "$add"
220
+ // AuditLogChangeKeyRoleRemove is sent when roles are removed from a user (array of discord.PartialRole JSON)
221
+ AuditLogChangeKeyRoleRemove AuditLogChangeKey = "$remove"
222
+ )
223
+
125
224
// AuditLog (https://discord.com/developers/docs/resources/audit-log) These are logs of events that occurred, accessible via the Discord
126
225
type AuditLog struct {
127
226
ApplicationCommands []ApplicationCommand `json:"application_commands"`
@@ -174,71 +273,33 @@ func (l *AuditLog) UnmarshalJSON(data []byte) error {
174
273
// AuditLogEntry (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object)
175
274
type AuditLogEntry struct {
176
275
TargetID * snowflake.ID `json:"target_id"`
177
- Changes []AuditLogChangeKey `json:"changes"`
276
+ Changes []AuditLogChange `json:"changes"`
178
277
UserID snowflake.ID `json:"user_id"`
179
278
ID snowflake.ID `json:"id"`
180
279
ActionType AuditLogEvent `json:"action_type"`
181
280
Options * OptionalAuditLogEntryInfo `json:"options"`
182
281
Reason * string `json:"reason"`
183
282
}
184
283
185
- // AuditLogChangeKey (https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-key) is data representing changes values/settings in an audit log.
186
- type AuditLogChangeKey struct {
187
- Name * string `json:"name"`
188
- Description * string `json:"description"`
189
- IconHash * string `json:"icon_hash"`
190
- SplashHash * string `json:"splash_hash"`
191
- DiscoverySplashHash * string `json:"discovery_splash_hash"`
192
- BannerHash * string `json:"banner_hash"`
193
- OwnerID * snowflake.ID `json:"owner_id"`
194
- Region * string `json:"region"`
195
- PreferredLocale * string `json:"preferred_locale"`
196
- AFKChannelID * snowflake.ID `json:"afk_channel_id"`
197
- AFKTimeout * int `json:"afk_timeout"`
198
- RulesChannelID * snowflake.ID `json:"rules_channel_id"`
199
- PublicUpdatesChannelID * snowflake.ID `json:"public_updates_channel_id"`
200
- MFALevel * MFALevel `json:"mfa_level"`
201
- VerificationLevel * VerificationLevel `json:"verification_level"`
202
- ExplicitContentFilterLevel * ExplicitContentFilterLevel `json:"explicit_content_filter"`
203
- DefaultMessageNotifications * MessageNotificationsLevel `json:"default_message_notifications"`
204
- VanityURLCode * string `json:"vanity_url_code"`
205
- Add []PartialRole `json:"$add"`
206
- Remove []PartialRole `json:"$remove"`
207
- PruneDeleteDays * int `json:"prune_delete_days"`
208
- WidgetEnabled * bool `json:"widget_enabled"`
209
- WidgetChannelID * string `json:"widget_channel_id"`
210
- SystemChannelID * string `json:"system_channel_id"`
211
- Position * int `json:"position"`
212
- Topic * string `json:"topic"`
213
- Bitrate * int `json:"bitrate"`
214
- PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"`
215
- NSFW * bool `json:"nsfw"`
216
- ApplicationID * snowflake.ID `json:"application_id"`
217
- RateLimitPerUser * int `json:"ratelimit_per_user"`
218
- Permissions * string `json:"permissions"`
219
- Color * int `json:"color"`
220
- Hoist * bool `json:"hoist"`
221
- Mentionable * bool `json:"mentionable"`
222
- Allow * Permissions `json:"allow"`
223
- Deny * Permissions `json:"deny"`
224
- Code * string `json:"code"`
225
- ChannelID * snowflake.ID `json:"channel_id"`
226
- InviterID * snowflake.ID `json:"inviter_id"`
227
- MaxUses * int `json:"max_uses"`
228
- Uses * int `json:"uses"`
229
- MaxAge * string `json:"max_age"`
230
- Temporary * bool `json:"temporary"`
231
- Deaf * bool `json:"deaf"`
232
- Mute * bool `json:"mute"`
233
- Nick * string `json:"nick"`
234
- AvatarHash * string `json:"avatar_hash"`
235
- ID * snowflake.ID `json:"id"`
236
- Type any `json:"type"`
237
- EnableEmoticons * bool `json:"enable_emoticons"`
238
- ExpireBehavior * IntegrationExpireBehavior `json:"expire_behavior"`
239
- ExpireGracePeriod * int `json:"expire_grace_period"`
240
- UserLimit * int `json:"user_limit"`
241
- PrivacyLevel * StagePrivacyLevel `json:"privacy_level"`
284
+ // AuditLogChange (https://discord.com/developers/docs/resources/audit-log#audit-log-change-object) contains what was changed.
285
+ // For a list of possible keys & values see the discord documentation.
286
+ type AuditLogChange struct {
287
+ // NewValue is the new value of the key after the change as a json.RawMessage.
288
+ NewValue json.RawMessage `json:"new_value"`
289
+ // OldValue is the old value of the key before the change as a json.RawMessage.
290
+ OldValue json.RawMessage `json:"old_value"`
291
+ // Key is the key of the change.
292
+ Key AuditLogChangeKey `json:"key"`
293
+ }
294
+
295
+ // UnmarshalNewValue unmarshals the NewValue field into the provided type.
296
+ func (c * AuditLogChange ) UnmarshalNewValue (v any ) error {
297
+ return json .Unmarshal (c .NewValue , v )
298
+ }
299
+
300
+ // UnmarshalOldValue unmarshals the OldValue field into the provided type.
301
+ func (c * AuditLogChange ) UnmarshalOldValue (v any ) error {
302
+ return json .Unmarshal (c .OldValue , v )
242
303
}
243
304
244
305
// OptionalAuditLogEntryInfo (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info)
0 commit comments