valgorithms / discord-php-eventlogger
DiscordPHP EventLogger is a tool designed to generate guild-specific audit logs for the DiscordPHP API library.
Package info
github.com/Valgorithms/DiscordPHP-EventLogger
pkg:composer/valgorithms/discord-php-eventlogger
Requires
- php: ^8.3
- team-reflex/discord-php: ^10.0.0 || dev-master
Requires (Dev)
- laravel/pint: ^1.21
- phpunit/phpunit: ^9.4.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-09 22:29:02 UTC
README
DiscordPHP EventLogger is a drop-in audit logger for the DiscordPHP library. It listens for gateway events and posts a formatted embed to each guild's configured log channel.
Features
- Member joins / leaves / updates (nickname, roles, avatar)
- Message deletions and edits (a line-by-line
difffor edits, cached-content aware) - Role creations / deletions / updates
- Channel creations / deletions / updates
- Bans and unbans
- Opt-in
USER_UPDATE - Per-guild log channels, from an env var or set at runtime
- Any default handler can be overridden with your own callable
Requirements
- PHP 8.3+
team-reflex/discord-php^10
Installation
composer require valgorithms/discord-php-eventlogger
Usage
require 'vendor/autoload.php'; use Discord\Discord; use EventLogger\EventLogger; $discord = new Discord(['token' => 'YOUR_DISCORD_BOT_TOKEN']); // Default event set (EventLogger::DEFAULT_EVENTS): $logger = new EventLogger($discord); // Or pick the events, and override a handler with your own callable // (it receives the gateway payload plus the Discord client): $logger = new EventLogger($discord, [ 'MESSAGE_DELETE', 'GUILD_MEMBER_ADD', 'GUILD_BAN_ADD' => fn(\Discord\Parts\Guild\Ban $ban, Discord $discord) => $discord->getLogger()->notice("Banned {$ban->user} in {$ban->guild_id}"), ]); $discord->run();
Configuring log channels
Set DISCORDPHP_EVENTLOGGER_GUILD_CHANNELS to a comma-separated list of
guildId-channelId pairs:
DISCORDPHP_EVENTLOGGER_GUILD_CHANNELS=1077144430588469349-1077144432463314998,1253459964849164328-1253480680583860367
Blank / malformed entries are ignored, and an unset variable is fine — add channels at runtime instead:
$logger->addLogChannel('1077144430588469349', '1077144432463314998'); $logger->removeLogGuild('1077144430588469349');
Development
composer install composer unit # phpunit composer pint # code style
License
MIT — see LICENSE.md.
Credits
DiscordPHP EventLogger by Valithor Obsidion