Skip to content

Commit bb0b1a7

Browse files
authored
Merge pull request #38 from WeebHiroyuki/feature/audit-log
feat: audit log
2 parents e10263b + cf2fa3f commit bb0b1a7

File tree

3 files changed

+232
-0
lines changed

3 files changed

+232
-0
lines changed

api/audit_log.go

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package api
2+
3+
// 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.
4+
type AuditLogChangeKey struct {
5+
Name *string `json:"name"`
6+
Description *string `json:"description"`
7+
IconHash *string `json:"icon_hash"`
8+
SplashHash *string `json:"splash_hash"`
9+
DiscoverySplashHash *string `json:"discovery_splash_hash"`
10+
BannerHash *string `json:"banner_hash"`
11+
OwnerID *Snowflake `json:"owner_id"`
12+
Region *string `json:"region"`
13+
PreferredLocale *string `json:"preferred_locale"`
14+
AFKChannelID *Snowflake `json:"afk_channel_id"`
15+
AFKTimeout *int `json:"afk_timeout"`
16+
RulesChannelID *Snowflake `json:"rules_channel_id"`
17+
PublicUpdatesChannelID *Snowflake `json:"public_updates_channel_id"`
18+
MFALevel *MFALevel `json:"mfa_level"`
19+
VerificationLevel *VerificationLevel `json:"verification_level"`
20+
ExplicitContentFilterLevel *ExplicitContentFilterLevel `json:"explicit_content_filter"`
21+
DefaultMessageNotifications *MessageNotifications `json:"default_message_notifications"`
22+
VanityURLCode *string `json:"vanity_url_code"`
23+
Add []Role `json:"$add"`
24+
Remove []Role `json:"$remove"`
25+
PruneDeleteDays *int `json:"prune_delete_days"`
26+
WidgetEnabled *bool `json:"widget_enabled"`
27+
WidgetChannelID *string `json:"widget_channel_id"`
28+
SystemChannelID *string `json:"system_channel_id"`
29+
Position *int `json:"position"`
30+
Topic *string `json:"topic"`
31+
Bitrate *int `json:"bitrate"`
32+
PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"`
33+
NSFW *bool `json:"nsfw"`
34+
ApplicationID *Snowflake `json:"application_id"`
35+
RateLimitPerUser *int `json:"ratelimit_per_user"`
36+
Permissions *string `json:"permissions"`
37+
Color *int `json:"color"`
38+
Hoist *bool `json:"hoist"`
39+
Mentionable *bool `json:"mentionable"`
40+
Allow *Permissions `json:"allow"`
41+
Deny *Permissions `json:"deny"`
42+
Code *string `json:"code"`
43+
ChannelID *Snowflake `json:"channel_id"`
44+
InviterID *Snowflake `json:"inviter_id"`
45+
MaxUses *int `json:"max_uses"`
46+
Uses *int `json:"uses"`
47+
MaxAge *string `json:"max_age"`
48+
Temporary *bool `json:"temporary"`
49+
Deaf *bool `json:"deaf"`
50+
Mute *bool `json:"mute"`
51+
Nick *string `json:"nick"`
52+
AvatarHash *string `json:"avatar_hash"`
53+
ID *Snowflake `json:"id"`
54+
Type interface{} `json:"type"`
55+
EnableEmoticons *bool `json:"enable_emoticons"`
56+
ExpireBehavior *int `json:"expire_behavior"`
57+
ExpireGracePeriod *int `json:"expire_grace_period"`
58+
UserLimit *int `json:"user_limit"`
59+
PrivacyLevel *int `json:"privacy_level"`
60+
}
61+
62+
// AuditLogEvent is an 8-bit unsigned integer representing an audit log event.
63+
type AuditLogEvent int
64+
65+
// AuditLogEventGuildUpdate
66+
const (
67+
AuditLogEventGuildUpdate AuditLogEvent = 1
68+
)
69+
70+
// AuditLogEventChannelCreate
71+
const (
72+
AuditLogEventChannelCreate AuditLogEvent = iota + 10
73+
AuditLogEventChannelUpdate
74+
AuditLogEventChannelDelete
75+
AuditLogEventChannelOverwriteCreate
76+
AuditLogEventChannelOverwriteUpdate
77+
AuditLogEventChannelOverwriteDelete
78+
)
79+
80+
// AuditLogEventMemberKick
81+
const (
82+
AuditLogEventMemberKick AuditLogEvent = iota + 20
83+
AuditLogEventMemberPrune
84+
AuditLogEventMemberBanAdd
85+
AuditLogEventMemberBanRemove
86+
AuditLogEventMemberUpdate
87+
AuditLogEventMemberRoleUpdate
88+
AuditLogEventMemberMove
89+
AuditLogEventMemberDisconnect
90+
AuditLogEventBotAdd
91+
)
92+
93+
// AuditLogEventRoleCreate
94+
const (
95+
AuditLogEventRoleCreate AuditLogEvent = iota + 30
96+
AuditLogEventRoleUpdate
97+
AuditLogEventRoleDelete
98+
)
99+
100+
// AuditLogEventInviteCreate
101+
const (
102+
AuditLogEventInviteCreate AuditLogEvent = iota + 40
103+
AuditLogEventInviteUpdate
104+
AuditLogEventInviteDelete
105+
)
106+
107+
// AuditLogEventWebhookCreate
108+
const (
109+
AuditLogEventWebhookCreate AuditLogEvent = iota + 50
110+
AuditLogEventWebhookUpdate
111+
AuditLogEventWebhookDelete
112+
)
113+
114+
// AuditLogEventEmojiCreate
115+
const (
116+
AuditLogEventEmojiCreate AuditLogEvent = iota + 60
117+
AuditLogEventEmojiUpdate
118+
AuditLogEventEmojiDelete
119+
)
120+
121+
// AuditLogEventMessageDelete
122+
const (
123+
AuditLogEventMessageDelete AuditLogEvent = iota + 72
124+
AuditLogEventMessageBulkDelete
125+
AuditLogEventMessagePin
126+
AuditLogEventMessageUnpin
127+
)
128+
129+
// AuditLogEventIntegrationCreate
130+
const (
131+
AuditLogEventIntegrationCreate AuditLogEvent = iota + 80
132+
AuditLogEventIntegrationUpdate
133+
AuditLogEventIntegrationDelete
134+
AuditLogEventStageInstanceCreate
135+
AuditLogEventStageInstanceUpdate
136+
AuditLogEventStageInstanceDelete
137+
)
138+
139+
// OptionalAuditLogEntryInfo (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info)
140+
type OptionalAuditLogEntryInfo struct {
141+
DeleteMemberDays *string `json:"delete_member_days"`
142+
MembersRemoved *string `json:"members_removed"`
143+
ChannelID *Snowflake `json:"channel_id"`
144+
MessageID *Snowflake `json:"message_id"`
145+
Count *string `json:"count"`
146+
ID *string `json:"id"`
147+
Type *string `json:"type"`
148+
RoleName *string `json:"role_name"`
149+
}
150+
151+
// AuditLogEntry (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object)
152+
type AuditLogEntry struct {
153+
TargetID *Snowflake `json:"target_id"`
154+
Changes []AuditLogChangeKey `json:"changes"`
155+
UserID Snowflake `json:"user_id"`
156+
ID Snowflake `json:"id"`
157+
ActionType AuditLogEvent `json:"action_type"`
158+
Options *OptionalAuditLogEntryInfo `json:"options"`
159+
Reason *string `json:"reason"`
160+
}
161+
162+
// AuditLog (https://discord.com/developers/docs/resources/audit-log) These are logs of events that occurred, accessible via the Discord API.
163+
type AuditLog struct {
164+
Webhooks []Webhook
165+
Users []User
166+
Entries []AuditLogEntry
167+
Integrations []Integration
168+
}

api/integration.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package api
2+
3+
// IntegrationAccount (https://discord.com/developers/docs/resources/guild#integration-account-object)
4+
type IntegrationAccount struct {
5+
ID string `json:"id"`
6+
Name string `json:"name"`
7+
}
8+
9+
// IntegrationApplication (https://discord.com/developers/docs/resources/guild#integration-application-object)
10+
type IntegrationApplication struct {
11+
ID Snowflake `json:"id"`
12+
Name string `json:"name"`
13+
Icon string `json:"icon"`
14+
Description string `json:"description"`
15+
Summary string `json:"summary"`
16+
Bot *User `json:"bot"`
17+
}
18+
19+
// Integration (https://discord.com/developers/docs/resources/guild#integration-object)
20+
type Integration struct {
21+
ID Snowflake `json:"id"`
22+
Name string `json:"name"`
23+
Type string `json:"type"`
24+
Enabled bool `json:"enabled"`
25+
Syncing *bool `json:"syncing"`
26+
RoleID *Snowflake `json:"role_id"`
27+
EnableEmoticons *bool `json:"enable_emoticons"`
28+
ExpireBehavior *int `json:"expire_behavior"`
29+
ExpireGracePeriod *int `json:"expire_grace_period"`
30+
User *User `json:"user"`
31+
Account IntegrationAccount `json:"account"`
32+
SyncedAt *string `json:"synced_at"`
33+
SubscriberCount *int `json:"subscriber_account"`
34+
Revoked *bool `json:"revoked"`
35+
Application *IntegrationApplication `json:"application"`
36+
}

api/webhook.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package api
2+
3+
// WebhookType (https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types)
4+
type WebhookType int
5+
6+
// Incoming
7+
const (
8+
Incoming WebhookType = iota + 1
9+
ChannelFollower
10+
Application
11+
)
12+
13+
// Webhook (https://discord.com/developers/docs/resources/webhook) is a way to post messages to Discord using the Discord API which do not require bot authentication or use.
14+
type Webhook struct {
15+
ID Snowflake `json:"id"`
16+
Type WebhookType `json:"type"`
17+
Username Snowflake `json:"username"`
18+
GuildID *Snowflake `json:"guild_id"`
19+
ChannelID Snowflake `json:"channel_id"`
20+
User *User `json:"user"`
21+
Name string `json:"name"`
22+
Avatar string `json:"avatar"`
23+
Token *string `json:"token"`
24+
ApplicationID *Snowflake `json:"application_id"`
25+
SourceGuild *Guild `json:"source_guild"`
26+
SourceChannel *TextChannel `json:"source_channel"`
27+
URL *string `json:"url"`
28+
}

0 commit comments

Comments
 (0)