-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from WeebHiroyuki/feature/audit-log
feat: audit log
- Loading branch information
Showing
3 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
package api | ||
|
||
// 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. | ||
type AuditLogChangeKey struct { | ||
Name *string `json:"name"` | ||
Description *string `json:"description"` | ||
IconHash *string `json:"icon_hash"` | ||
SplashHash *string `json:"splash_hash"` | ||
DiscoverySplashHash *string `json:"discovery_splash_hash"` | ||
BannerHash *string `json:"banner_hash"` | ||
OwnerID *Snowflake `json:"owner_id"` | ||
Region *string `json:"region"` | ||
PreferredLocale *string `json:"preferred_locale"` | ||
AFKChannelID *Snowflake `json:"afk_channel_id"` | ||
AFKTimeout *int `json:"afk_timeout"` | ||
RulesChannelID *Snowflake `json:"rules_channel_id"` | ||
PublicUpdatesChannelID *Snowflake `json:"public_updates_channel_id"` | ||
MFALevel *MFALevel `json:"mfa_level"` | ||
VerificationLevel *VerificationLevel `json:"verification_level"` | ||
ExplicitContentFilterLevel *ExplicitContentFilterLevel `json:"explicit_content_filter"` | ||
DefaultMessageNotifications *MessageNotifications `json:"default_message_notifications"` | ||
VanityURLCode *string `json:"vanity_url_code"` | ||
Add []Role `json:"$add"` | ||
Remove []Role `json:"$remove"` | ||
PruneDeleteDays *int `json:"prune_delete_days"` | ||
WidgetEnabled *bool `json:"widget_enabled"` | ||
WidgetChannelID *string `json:"widget_channel_id"` | ||
SystemChannelID *string `json:"system_channel_id"` | ||
Position *int `json:"position"` | ||
Topic *string `json:"topic"` | ||
Bitrate *int `json:"bitrate"` | ||
PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` | ||
NSFW *bool `json:"nsfw"` | ||
ApplicationID *Snowflake `json:"application_id"` | ||
RateLimitPerUser *int `json:"ratelimit_per_user"` | ||
Permissions *string `json:"permissions"` | ||
Color *int `json:"color"` | ||
Hoist *bool `json:"hoist"` | ||
Mentionable *bool `json:"mentionable"` | ||
Allow *Permissions `json:"allow"` | ||
Deny *Permissions `json:"deny"` | ||
Code *string `json:"code"` | ||
ChannelID *Snowflake `json:"channel_id"` | ||
InviterID *Snowflake `json:"inviter_id"` | ||
MaxUses *int `json:"max_uses"` | ||
Uses *int `json:"uses"` | ||
MaxAge *string `json:"max_age"` | ||
Temporary *bool `json:"temporary"` | ||
Deaf *bool `json:"deaf"` | ||
Mute *bool `json:"mute"` | ||
Nick *string `json:"nick"` | ||
AvatarHash *string `json:"avatar_hash"` | ||
ID *Snowflake `json:"id"` | ||
Type interface{} `json:"type"` | ||
EnableEmoticons *bool `json:"enable_emoticons"` | ||
ExpireBehavior *int `json:"expire_behavior"` | ||
ExpireGracePeriod *int `json:"expire_grace_period"` | ||
UserLimit *int `json:"user_limit"` | ||
PrivacyLevel *int `json:"privacy_level"` | ||
} | ||
|
||
// AuditLogEvent is an 8-bit unsigned integer representing an audit log event. | ||
type AuditLogEvent int | ||
|
||
// AuditLogEventGuildUpdate | ||
const ( | ||
AuditLogEventGuildUpdate AuditLogEvent = 1 | ||
) | ||
|
||
// AuditLogEventChannelCreate | ||
const ( | ||
AuditLogEventChannelCreate AuditLogEvent = iota + 10 | ||
AuditLogEventChannelUpdate | ||
AuditLogEventChannelDelete | ||
AuditLogEventChannelOverwriteCreate | ||
AuditLogEventChannelOverwriteUpdate | ||
AuditLogEventChannelOverwriteDelete | ||
) | ||
|
||
// AuditLogEventMemberKick | ||
const ( | ||
AuditLogEventMemberKick AuditLogEvent = iota + 20 | ||
AuditLogEventMemberPrune | ||
AuditLogEventMemberBanAdd | ||
AuditLogEventMemberBanRemove | ||
AuditLogEventMemberUpdate | ||
AuditLogEventMemberRoleUpdate | ||
AuditLogEventMemberMove | ||
AuditLogEventMemberDisconnect | ||
AuditLogEventBotAdd | ||
) | ||
|
||
// AuditLogEventRoleCreate | ||
const ( | ||
AuditLogEventRoleCreate AuditLogEvent = iota + 30 | ||
AuditLogEventRoleUpdate | ||
AuditLogEventRoleDelete | ||
) | ||
|
||
// AuditLogEventInviteCreate | ||
const ( | ||
AuditLogEventInviteCreate AuditLogEvent = iota + 40 | ||
AuditLogEventInviteUpdate | ||
AuditLogEventInviteDelete | ||
) | ||
|
||
// AuditLogEventWebhookCreate | ||
const ( | ||
AuditLogEventWebhookCreate AuditLogEvent = iota + 50 | ||
AuditLogEventWebhookUpdate | ||
AuditLogEventWebhookDelete | ||
) | ||
|
||
// AuditLogEventEmojiCreate | ||
const ( | ||
AuditLogEventEmojiCreate AuditLogEvent = iota + 60 | ||
AuditLogEventEmojiUpdate | ||
AuditLogEventEmojiDelete | ||
) | ||
|
||
// AuditLogEventMessageDelete | ||
const ( | ||
AuditLogEventMessageDelete AuditLogEvent = iota + 72 | ||
AuditLogEventMessageBulkDelete | ||
AuditLogEventMessagePin | ||
AuditLogEventMessageUnpin | ||
) | ||
|
||
// AuditLogEventIntegrationCreate | ||
const ( | ||
AuditLogEventIntegrationCreate AuditLogEvent = iota + 80 | ||
AuditLogEventIntegrationUpdate | ||
AuditLogEventIntegrationDelete | ||
AuditLogEventStageInstanceCreate | ||
AuditLogEventStageInstanceUpdate | ||
AuditLogEventStageInstanceDelete | ||
) | ||
|
||
// OptionalAuditLogEntryInfo (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info) | ||
type OptionalAuditLogEntryInfo struct { | ||
DeleteMemberDays *string `json:"delete_member_days"` | ||
MembersRemoved *string `json:"members_removed"` | ||
ChannelID *Snowflake `json:"channel_id"` | ||
MessageID *Snowflake `json:"message_id"` | ||
Count *string `json:"count"` | ||
ID *string `json:"id"` | ||
Type *string `json:"type"` | ||
RoleName *string `json:"role_name"` | ||
} | ||
|
||
// AuditLogEntry (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object) | ||
type AuditLogEntry struct { | ||
TargetID *Snowflake `json:"target_id"` | ||
Changes []AuditLogChangeKey `json:"changes"` | ||
UserID Snowflake `json:"user_id"` | ||
ID Snowflake `json:"id"` | ||
ActionType AuditLogEvent `json:"action_type"` | ||
Options *OptionalAuditLogEntryInfo `json:"options"` | ||
Reason *string `json:"reason"` | ||
} | ||
|
||
// AuditLog (https://discord.com/developers/docs/resources/audit-log) These are logs of events that occurred, accessible via the Discord API. | ||
type AuditLog struct { | ||
Webhooks []Webhook | ||
Users []User | ||
Entries []AuditLogEntry | ||
Integrations []Integration | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package api | ||
|
||
// IntegrationAccount (https://discord.com/developers/docs/resources/guild#integration-account-object) | ||
type IntegrationAccount struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
} | ||
|
||
// IntegrationApplication (https://discord.com/developers/docs/resources/guild#integration-application-object) | ||
type IntegrationApplication struct { | ||
ID Snowflake `json:"id"` | ||
Name string `json:"name"` | ||
Icon string `json:"icon"` | ||
Description string `json:"description"` | ||
Summary string `json:"summary"` | ||
Bot *User `json:"bot"` | ||
} | ||
|
||
// Integration (https://discord.com/developers/docs/resources/guild#integration-object) | ||
type Integration struct { | ||
ID Snowflake `json:"id"` | ||
Name string `json:"name"` | ||
Type string `json:"type"` | ||
Enabled bool `json:"enabled"` | ||
Syncing *bool `json:"syncing"` | ||
RoleID *Snowflake `json:"role_id"` | ||
EnableEmoticons *bool `json:"enable_emoticons"` | ||
ExpireBehavior *int `json:"expire_behavior"` | ||
ExpireGracePeriod *int `json:"expire_grace_period"` | ||
User *User `json:"user"` | ||
Account IntegrationAccount `json:"account"` | ||
SyncedAt *string `json:"synced_at"` | ||
SubscriberCount *int `json:"subscriber_account"` | ||
Revoked *bool `json:"revoked"` | ||
Application *IntegrationApplication `json:"application"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package api | ||
|
||
// WebhookType (https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types) | ||
type WebhookType int | ||
|
||
// Incoming | ||
const ( | ||
Incoming WebhookType = iota + 1 | ||
ChannelFollower | ||
Application | ||
) | ||
|
||
// 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. | ||
type Webhook struct { | ||
ID Snowflake `json:"id"` | ||
Type WebhookType `json:"type"` | ||
Username Snowflake `json:"username"` | ||
GuildID *Snowflake `json:"guild_id"` | ||
ChannelID Snowflake `json:"channel_id"` | ||
User *User `json:"user"` | ||
Name string `json:"name"` | ||
Avatar string `json:"avatar"` | ||
Token *string `json:"token"` | ||
ApplicationID *Snowflake `json:"application_id"` | ||
SourceGuild *Guild `json:"source_guild"` | ||
SourceChannel *TextChannel `json:"source_channel"` | ||
URL *string `json:"url"` | ||
} |