audit

package
v0.0.0-...-d49a382 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// String	name changed.
	//
	// Applies to: Guild
	ChangeKeyName = "name"
	// String	icon changed.
	//
	// Applies to: Guild
	ChangeKeyIconHash = "icon_hash"
	// String	invite splash page artwork changed.
	//
	// Applies to: Guild
	ChangeKeySplashHash = "splash_hash"
	// Snowflake	owner changed.
	//
	// Applies to: Guild
	ChangeKeyOwnerId = "owner_id"
	// String	region changed.
	//
	// Applies to: Guild
	ChangeKeyRegion = "region"
	// Snowflake	afk channel changed.
	//
	// Applies to: Guild
	ChangeKeyAfkChannelId = "afk_channel_id"
	// Integer	afk timeout duration changed.
	//
	// Applies to: Guild
	ChangeKeyAfkTimeout = "afk_timeout"
	// Integer	two-factor auth requirement changed.
	//
	// Applies to: Guild
	ChangeKeyMfaLevel = "mfa_level"
	// Integer	required verification level changed.
	//
	// Applies to: Guild
	ChangeKeyVerificationLevel = "verification_level"
	// Integer	change in whose messages are scanned and deleted for explicit content in the server.
	//
	// Applies to: Guild
	ChangeKeyExplicitContentFilter = "explicit_content_filter"
	// Integer	default message notification level changed.
	//
	// Applies to: Guild
	ChangeKeyDefaultMessageNotifications = "default_message_notifications"
	// String	guild invite vanity url changed.
	//
	// Applies to: Guild
	ChangeKeyVanityUrlCode = "vanity_url_code"
	// Array of partial role objects	new role added.
	//
	// Applies to: Guild
	ChangeKeyRoleAdd = "add"
	// Array of partial role objects	role removed.
	//
	// Applies to: Guild
	ChangeKeyRoleRemove = "remove"
	// Integer	change in number of days after which inactive and role-unassigned members are kicked.
	//
	// Applies to: Guild
	ChangeKeyPruneDeleteDays = "prune_delete_days"
	// Boolean	server widget enabled/disable.
	//
	// Applies to: Guild
	ChangeKeyWidgetEnabled = "widget_enabled"
	// Snowflake	channel id of the server widget changed.
	//
	// Applies to: Guild
	ChangeKeyWidgetChannelId = "widget_channel_id"
	// Snowflake	id of the system channel changed.
	//
	// Applies to: Guild
	ChangeKeySystemChannelId = "system_channel_id"
	// Integer	text or voice channel position changed.
	//
	// Applies to: Channel
	ChangeKeyPosition = "position"
	// String	text channel topic changed.
	//
	// Applies to: Channel
	ChangeKeyTopic = "topic"
	// Integer	voice channel bitrate changed.
	//
	// Applies to: Channel
	ChangeKeyBitrate = "bitrate"
	// Array of channel overwrite objects	permissions on a channel changed.
	//
	// Applies to: Channel
	ChangeKeyPermissionOverwrites = "permission_overwrites"
	// Boolean	channel nsfw restriction changed.
	//
	// Applies to: Channel
	ChangeKeyNsfw = "nsfw"
	// Snowflake	application id of the added or removed webhook or bot.
	//
	// Applies to: Channel
	ChangeKeyApplicationId = "application_id"
	// Integer	amount of seconds a user has to wait before sending another message changed.
	//
	// Applies to: Channel
	ChangeKeyRateLimitPerUser = "rate_limit_per_user"
	// String	permissions for a role changed.
	//
	// Applies to: Role
	ChangeKeyPermissions = "permissions"
	// Integer	role color changed.
	//
	// Applies to: Role
	ChangeKeyColor = "color"
	// Boolean	role is now displayed/no longer displayed separate from online users.
	//
	// Applies to: Role
	ChangeKeyHoist = "hoist"
	// Boolean	role is now mentionable/unmentionable.
	//
	// Applies to: Role
	ChangeKeyMentionable = "mentionable"
	// String	a permission on a text or voice channel was allowed for a role.
	//
	// Applies to: Role
	ChangeKeyAllow = "allow"
	// String	a permission on a text or voice channel was denied for a role.
	//
	// Applies to: Role
	ChangeKeyDeny = "deny"
	// String	invite code changed.
	//
	// Applies to: Invite
	ChangeKeyCode = "code"
	// Snowflake	channel for invite code changed.
	//
	// Applies to: Invite
	ChangeKeyChannelId = "channel_id"
	// Snowflake	person who created invite code changed.
	//
	// Applies to: Invite
	ChangeKeyInviterId = "inviter_id"
	// Integer	change to max number of times invite code can be used.
	//
	// Applies to: Invite
	ChangeKeyMaxUses = "max_uses"
	// Integer	number of times invite code used changed.
	//
	// Applies to: Invite
	ChangeKeyUses = "uses"
	// Integer	how long invite code lasts changed.
	//
	// Applies to: Invite
	ChangeKeyMaxAge = "max_age"
	// Boolean	invite code is temporary/never expires.
	//
	// Applies to: Invite
	ChangeKeyTemporary = "temporary"
	// Boolean	user server deafened/undeafened.
	//
	// Applies to: User
	ChangeKeyDeaf = "deaf"
	// Boolean	user server muted/unmuted.
	//
	// Applies to: User
	ChangeKeyMute = "mute"
	// String	user nickname changed.
	//
	// Applies to: User
	ChangeKeyNick = "nick"
	// String	user avatar changed.
	//
	// Applies to: User
	ChangeKeyAvatarHash = "avatar_hash"
	// Snowflake	the id of the changed entity - sometimes used in conjunction with other keys.
	//
	// Applies to: Any
	ChangeKeyId = "id"
	// Integer (channel type) or string	type of entity created.
	//
	// Applies to: Any
	ChangeKeyType = "type"
	// Boolean	integration emoticons enabled/disabled.
	//
	// Applies to: Integration
	ChangeKeyEnableEmoticons = "enable_emoticons"
	// Integer	integration expiring subscriber behavior changed.
	//
	// Applies to: Integration
	ChangeKeyExpireBehavior = "expire_behavior"
	// Integer	integration expire grace period changed.
	//
	// Applies to: Integration
	ChangeKeyExpireGracePeriod = "expire_grace_period"
)

Variables

View Source
var (
	ErrBadLogEvent = errors.New("unrecognized audit log event value")
)
View Source
var (
	ErrBadReasonLength = errors.New("audit log entry reason values cannot be greater than 512 characters")
)

Functions

This section is empty.

Types

type ChangeKey

type ChangeKey string

TODO: this is a temporary measure until a more type-safe way to handle

changes is added.

type Log

type Log interface {
	// Webhooks returns the current value of this record's `webhooks` field.
	//
	// The `webhooks` field contains a list of webhooks found in the audit log.
	Webhooks() []discord.Webhook

	// SetWebhooks overwrites the current value of this record's `webhooks` field.
	SetWebhooks([]discord.Webhook) Log

	// Users returns the current value of this record's `users` field.
	//
	// The `users` field contains a list of users found in the audit log.
	Users() []discord.User

	// SetUsers overwrites the current value of this record's `users` field.
	SetUsers([]discord.User) Log

	// AuditLogEntries returns the current value of this record's
	// `audit_log_entries` field.
	//
	// The `audit_log_entries` field contains a list of audit log entries.
	AuditLogEntries() []LogEntry

	// SetAuditLogEntries overwrites the current value of this record's
	// `audit_log_entries` field.
	SetAuditLogEntries([]LogEntry) Log

	// Integrations returns the current value of this record's `integrations`
	// field.
	//
	// The `integrations` field contains a list of partial integration objects.
	Integrations() []discord.Integration

	// SetIntegrations overwrites the current value of this record's
	// `integrations` field.
	SetIntegrations([]discord.Integration) Log
}

type LogChange

type LogChange interface {
	// NewValue returns the current value of this record's `new_value` field.
	//
	// The `new_value` field contains the new value of the key.
	//
	// If this method is called on a field that is unset, this method will panic.
	// Use NewValueIsSet to check if the field is present before use.
	NewValue() interface{}

	// NewValueIsSet returns whether this record's `new_value` field is currently
	// present.
	NewValueIsSet() bool

	// SetNewValue overwrites the current value of this record's `new_value`
	// field.
	SetNewValue(interface{}) LogChange

	// UnsetNewValue removes this record's `new_value` field.
	UnsetNewValue() LogChange

	// OldValue returns the current value of this record's `old_value` field.
	//
	// The `old_value` field contains the old value of the key.
	//
	// If this method is called on a field that is unset, this method will panic.
	// Use OldValueIsSet to check if the field is present before use.
	OldValue() interface{}

	// OldValueIsSet returns whether this record's `old_value` field is currently
	// present.
	OldValueIsSet() bool

	// SetOldValue overwrites the current value of this record's `old_value`
	// field.
	SetOldValue(interface{}) LogChange

	// UnsetOldValue removes this record's `old_value` field.
	UnsetOldValue() LogChange

	// Key returns the current value of this record's `key` field.
	//
	// The `key` field contains the
	Key() ChangeKey

	// SetKey overwrites the current value of this record's `key` field.
	SetKey(ChangeKey) LogChange
}

type LogEntry

type LogEntry interface {
	json.Marshaler
	json.Unmarshaler

	gojay.MarshalerJSONObject
	gojay.UnmarshalerJSONObject

	dmeta.Sized
	dmeta.Validatable

	// TargetID returns the current value of this record's `target_id` field.
	//
	// The `target_id` field contains the id of the affected entity (webhook,
	// user, role, etc.).
	//
	// If this method is called on a field with a null value, this method will
	// panic.  Use TargetIDIsNull to check if the field is null before use.
	TargetID() string

	// TargetIDIsNull returns whether this record's `target_id` field is currently
	// null.
	TargetIDIsNull() bool

	// SetTargetID overwrites the current value of this record's `target_id`
	// field.
	SetTargetID(string) LogEntry

	// SetNullTargetID overwrites the current value of this record's `target_id`
	// field with `null`.
	SetNullTargetID() LogEntry

	// Changes returns the current value of this record's `changes` field.
	//
	// The `changes` field contains an array of changes made to the target_id.
	//
	// If this method is called on a field that is unset, this method will panic.
	// Use ChangesIsSet to check if the field is present before use.
	Changes() []LogChange

	// ChangesIsSet returns whether this record's `changes` field is currently
	// present.
	ChangesIsSet() bool

	// SetChanges overwrites the current value of this record's `changes` field.
	SetChanges([]LogChange) LogEntry

	// UnsetChanges removes this record's `changes` field.
	UnsetChanges() LogEntry

	// UserID returns the current value of this record's `user_id` field.
	//
	// The `user_id` field contains the id of the user who made the changes.
	UserID() discord.Snowflake

	// SetUserID overwrites the current value of this record's `user_id` field.
	SetUserID(discord.Snowflake) LogEntry

	// ID returns the current value of this record's `id` field.
	//
	// The `id` field contains the id of the entry.
	ID() discord.Snowflake

	// SetID overwrites the current value of this record's `id` field.
	SetID(discord.Snowflake) LogEntry

	// ActionType returns the current value of this record's `action_type` field.
	//
	// The `action_type` field contains the type of action that occurred.
	ActionType() LogEvent

	// SetActionType overwrites the current value of this record's `action_type`
	// field.
	SetActionType(LogEvent) LogEntry

	// Options returns the current value of this record's `options` field.
	//
	// The `options` field contains additional info for certain action types.
	//
	// If this method is called on a field that is unset, this method will panic.
	// Use OptionsIsSet to check if the field is present before use.
	Options() OptionalEntryInfo

	// OptionsIsSet returns whether this record's `options` field is currently
	// present.
	OptionsIsSet() bool

	// SetOptions overwrites the current value of this record's `options` field.
	SetOptions(OptionalEntryInfo) LogEntry

	// UnsetOptions removes this record's `options` field.
	UnsetOptions() LogEntry

	// Reason returns the current value of this record's `reason` field.
	//
	// The `reason` field contains the reason for the change (0-512 characters).
	//
	// If this method is called on a field that is unset, this method will panic.
	// Use ReasonIsSet to check if the field is present before use.
	Reason() LogReason

	// ReasonIsSet returns whether this record's `reason` field is currently
	// present.
	ReasonIsSet() bool

	// SetReason overwrites the current value of this record's `reason` field.
	SetReason(LogReason) LogEntry

	// UnsetReason removes this record's `reason` field.
	UnsetReason() LogEntry
}

type LogEvent

type LogEvent uint8
const (
	LogEventGuildUpdate            LogEvent = 1
	LogEventChannelCreate          LogEvent = 10
	LogEventChannelUpdate          LogEvent = 11
	LogEventChannelDelete          LogEvent = 12
	LogEventChannelOverwriteCreate LogEvent = 13
	LogEventChannelOverwriteUpdate LogEvent = 14
	LogEventChannelOverwriteDelete LogEvent = 15
	LogEventMemberKick             LogEvent = 20
	LogEventMemberPrune            LogEvent = 21
	LogEventMemberBanAdd           LogEvent = 22
	LogEventMemberBanRemove        LogEvent = 23
	LogEventMemberUpdate           LogEvent = 24
	LogEventMemberRoleUpdate       LogEvent = 25
	LogEventMemberMove             LogEvent = 26
	LogEventMemberDisconnect       LogEvent = 27
	LogEventBotAdd                 LogEvent = 28
	LogEventRoleCreate             LogEvent = 30
	LogEventRoleUpdate             LogEvent = 31
	LogEventRoleDelete             LogEvent = 32
	LogEventInviteCreate           LogEvent = 40
	LogEventInviteUpdate           LogEvent = 41
	LogEventInviteDelete           LogEvent = 42
	LogEventWebhookCreate          LogEvent = 50
	LogEventWebhookUpdate          LogEvent = 51
	LogEventWebhookDelete          LogEvent = 52
	LogEventEmojiCreate            LogEvent = 60
	LogEventEmojiUpdate            LogEvent = 61
	LogEventEmojiDelete            LogEvent = 62
	LogEventMessageDelete          LogEvent = 72
	LogEventMessageBulkDelete      LogEvent = 73
	LogEventMessagePin             LogEvent = 74
	LogEventMessageUnpin           LogEvent = 75
	LogEventIntegrationCreate      LogEvent = 80
	LogEventIntegrationUpdate      LogEvent = 81
	LogEventIntegrationDelete      LogEvent = 82
)

func (LogEvent) IsValid

func (l LogEvent) IsValid() bool

func (LogEvent) JSONSize

func (l LogEvent) JSONSize() int

func (LogEvent) Validate

func (l LogEvent) Validate() error

type LogReason

type LogReason string

func (LogReason) IsValid

func (l LogReason) IsValid() bool

func (LogReason) Validate

func (l LogReason) Validate() error

type OptionalEntryInfo

type OptionalEntryInfo interface {
	// DeleteMemberDays returns the current value of this record's
	// `delete_member_days` field.
	//
	// The `delete_member_days` field contains the number of days after which
	// inactive members were kicked.
	//
	// Applies to action type(s): MEMBER_PRUNE
	DeleteMemberDays() string

	// SetDeleteMemberDays overwrites the current value of this record's
	// `delete_member_days` field.
	SetDeleteMemberDays(string) OptionalEntryInfo

	// MembersRemoved returns the current value of this record's `members_removed`
	// field.
	//
	// The `members_removed` field contains the number of members removed by the
	// prune.
	//
	// Applies to action type(s): MEMBER_PRUNE
	MembersRemoved() string

	// SetMembersRemoved overwrites the current value of this record's
	// `members_removed` field.
	SetMembersRemoved(string) OptionalEntryInfo

	// ChannelID returns the current value of this record's `channel_id` field.
	//
	// The `channel_id` field contains the channel in which the entities were
	// targeted.
	//
	// Applies to action type(s): MEMBER_MOVE, MESSAGE_PIN, MESSAGE_UNPIN,
	// MESSAGE_DELETE
	ChannelID() discord.Snowflake

	// SetChannelID overwrites the current value of this record's `channel_id`
	// field.
	SetChannelID(discord.Snowflake) OptionalEntryInfo

	// MessageID returns the current value of this record's `message_id` field.
	//
	// The `message_id` field contains the id of the message that was targeted.
	//
	// Applies to action type(s): MESSAGE_PIN, MESSAGE_UNPIN
	MessageID() discord.Snowflake

	// SetMessageID overwrites the current value of this record's `message_id` field.
	SetMessageID(discord.Snowflake) OptionalEntryInfo

	// Count returns the current value of this record's `count` field.
	//
	// The `count` field contains the number of entities that were targeted.
	//
	// Applies to action type(s): MESSAGE_DELETE, MESSAGE_BULK_DELETE,
	// MEMBER_DISCONNECT, MEMBER_MOVE
	Count() string

	// SetCount overwrites the current value of this record's `count` field.
	SetCount(string) OptionalEntryInfo

	// ID returns the current value of this record's `id` field.
	//
	// The `id` field contains the id of the overwritten entity.
	//
	// Applies to action type(s): CHANNEL_OVERWRITE_CREATE,
	// CHANNEL_OVERWRITE_UPDATE, CHANNEL_OVERWRITE_DELETE
	ID() discord.Snowflake

	// SetID overwrites the current value of this record's `id` field.
	SetID(discord.Snowflake) OptionalEntryInfo

	// Type returns the current value of this record's `type` field.
	//
	// The `type` field contains the type of overwritten entity - "0" for "role"
	// or "1" for "member".
	//
	// Applies to action type(s): CHANNEL_OVERWRITE_CREATE,
	// CHANNEL_OVERWRITE_UPDATE, CHANNEL_OVERWRITE_DELETE
	Type() discord.OverwriteType

	// SetType overwrites the current value of this record's `type` field.
	SetType(discord.OverwriteType) OptionalEntryInfo

	// RoleName returns the current value of this record's `role_name` field.
	//
	// The `role_name` field contains the name of the role if type is "0" (not
	// present if type is "1").
	//
	// Applies to action type(s): CHANNEL_OVERWRITE_CREATE,
	// CHANNEL_OVERWRITE_UPDATE, CHANNEL_OVERWRITE_DELETE
	RoleName() string

	// SetRoleName overwrites the current value of this record's `role_name` field.
	SetRoleName(string) OptionalEntryInfo
}

TODO: The fields on this type seems pretty sus. Are they all strings? Are

they all required?  Its name is Optional, so perhaps all fields are
optional?

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL