FiniteReality/disccord

Support Audit Logs

abuneri opened this issue · 0 comments

The endpoint(s) are open now, probably will be released (on canary) very soon:tm:, so may as well prepare to support this so it's not forgotten later.
NOTE: will update the issue's task list if more things end up being needed

1. disccord::models

  • Build audit_logs model
  • model structure:
  • new classes needed for structure
    • std::vector<audit_log_entry>
    • audit_log_entry has a member std::vector<audit_log_change>
{
"users": ["<user models>"],
"audit_log_entries": [{
  "target_id": "<?snowflake>",
  "user_id": "<snowflake>",
  "id": "<snowflake>",
  "action_type": "<int enum>",
  "changes": [{
    "?old_value":"<snowflake>/<string>/<bool>/<int>",
    "new_value":"<snowflake>/<string>/<bool>/<int>",
    "key":"<key_types>"
    }]
  }]
}
  • key_types:
{
    NAME: "name",
    ICON_HASH: "icon_hash",
    SPLASH_HASH: "splash_hash",
    OWNER_ID: "owner_id",
    REGION: "region",
    AFK_CHANNEL_ID: "afk_channel_id",
    AFK_TIMEOUT: "afk_timeout",
    MFA_LEVEL: "mfa_level",
    WIDGET_ENABLED: "widget_enabled",
    WIDGET_CHANNEL_ID: "widget_channel_id",
    VERIFICATION_LEVEL: "verification_level",
    EXPLICIT_CONTENT_FILTER: "explicit_content_filter",
    DEFAULT_MESSAGE_NOTIFICATIONS: "default_message_notifications",
    VANITY_URL_CODE: "vanity_url_code",
    POSITION: "position",
    TOPIC: "topic",
    TYPE: "type",
    BITRATE: "bitrate",
    PERMISSION_OVERRIDES: "permission_overrides",
    ROLES_ADD: "$add",
    ROLES_REMOVE: "$remove",
    NICK: "nick",
    DEAF: "deaf",
    MUTE: "mute",
    PERMISSIONS: "permissions",
    COLOR: "color",
    HOIST: "hoist",
    MENTIONABLE: "mentionable",
    CODE: "code",
    CHANNEL_ID: "channel_id",
    INVITER_ID: "inviter_id",
    MAX_USES: "max_uses",
    USES: "uses",
    MAX_AGE: "max_age",
    TEMPORARY: "temporary",
    APPLICATION_ID: "application_id",
    AVATAR_HASH: "avatar_hash",
    ID: "id",
    PERMISSIONS_GRANTED: "allow",
    PERMISSIONS_DENIED: "deny",
    REASON: "reason"
}
  • action_type enums:
{
    ALL: null, (in our case, we will have ALL map to 0)
    GUILD_UPDATE: 1,
    CHANNEL_CREATE: 10,
    CHANNEL_UPDATE: 11,
    CHANNEL_DELETE: 12,
    CHANNEL_OVERWRITE_CREATE: 13,
    CHANNEL_OVERWRITE_UPDATE: 14,
    CHANNEL_OVERWRITE_DELETE: 15,
    MEMBER_KICK: 20,
    MEMBER_PRUNE: 21,
    MEMBER_BAN_ADD: 22,
    MEMBER_BAN_REMOVE: 23,
    MEMBER_UPDATE: 24,
    MEMBER_ROLE_UPDATE: 25,
    ROLE_CREATE: 30,
    ROLE_UPDATE: 31,
    ROLE_DELETE: 32,
    INVITE_CREATE: 40,
    INVITE_UPDATE: 41,
    INVITE_DELETE: 42,
    WEBHOOK_CREATE: 50,
    WEBHOOK_UPDATE: 51,
    WEBHOOK_DELETE: 52,
    EMOJI_CREATE: 60,
    EMOJI_UPDATE: 61,
    EMOJI_DELETE: 62
}
  • for the action_types, will build an enum class audit_logs_action_type.

2. disccord::rest

  • GET /guilds/{guild.id}/audit-logs
  • query string params:
limit: <int> (default is 50, can be 1-100)
query: <string> "before"/"after"
id : <snowflake>
action_type: <integer>