Skip to content

Audit Log (audit)

A shared service module that records operations that require auditing as embeds to a specified channel. It has no commands and is called by other modules.

  • Config key: audit
  • Source file: modules/audit.py

Recording Scope

Only meaningful admin / server-level operations are recorded, to avoid useless logs taking up space:

  • Commands marked with [ADMIN] / [MOD] (such as /delete, /lock, /reload, /perm…).
  • Modifications / operations at server scope (such as /lang scope:server, /vc join/leave, /move-channel).
  • Automated actions and errors (anti-spam auto kick / ban / mute, slash command errors).

Ordinary user-scope commands (such as /random, /uuid, /to-file, /lang (user scope)) are not recorded.

How It Works

After performing the operations above, other modules call AuditLogger.log(...), and the log is sent to:

  • Global channel: global_channel, where operations from all servers are sent.
  • Per-server channel: a channel configured individually for the corresponding server in guilds.

The two are independent: if both are configured, both channels receive the log (deduplicated per channel, with the global one taking precedence). The embed for each language is built only once and cached.

The bot needs Send Messages / Embed Links permissions in the log channel; the target must be a text channel or a thread, otherwise it will be skipped with a warning.

Log Content

Each log is an embed containing (displayed in the configured language):

  • Title: distinguishes manual / automatic operations and success / failure (✅ / ❌ / 🚨 / ⚠️).
  • Action: e.g. /delete, clear-message, antispam-auto-catch.
  • Actor: mention + username + ID.
  • Server, Channel (if any).
  • Detail: operation description (max 1024 characters).
  • Timestamp (UTC).

Which Operations Are Recorded

Source moduleAction name
toolsdelete, clear-message, move-channel
adminsync, reload, reload-all, reload-config
emojiemoji-update
locklock, unlock, plan-lock, unplan-lock
voicejoinvc, leavevc
permperm-add, perm-rm
announcesubscribe
langlang-server (server scope modifications only)
antispamantispam-auto-catch (automatic operation, includes failure records)
(global error handling)slash-error/<cmd>

Localization

Supports both Chinese and English. The language is set via the /lang command (priority: user setting > server setting > default zh); see the lang module docs for details.

Language valueDescription
zhChinese (default)
enEnglish

Configuration

yaml
audit:
  enabled: false
  global_channel: null    # Global log channel ID (null to disable)
  guilds: {}              # Log channels configured per server
  # Example (channel ID only):
  #   123456789:  987654321
FieldTypeDefaultDescription
enabledboolfalseWhether to enable the audit log
global_channelint | nullnullGlobal log channel ID (null to disable the global log)
guildsdict{}Configured per server, see below

How to write guilds

The key is the server ID (a number or string), and the value is a channel ID (a number) or an object { channel: channel ID }.

yaml
audit:
  enabled: true
  global_channel: 111111111111111111
  guilds:
    222222222222222222: 333333333333333333      # Shorthand: channel ID only
    444444444444444444:
      channel: 555555555555555555

TIP

If a module is enabled but audit.enabled is false, the related operations will not be logged (the module still works normally).

Released under the MIT License