Documentación / Developers / Cookbook / 8) Message logger
BuildSDK 0.10.1

8) Message logger

These docs are public. To publish a plugin you need a YourBot account: sign in to open the Dev Portal.

Log every non-bot message to a configurable mod channel (useful for audit trails). Reads message text, so it needs events:message_content.

from yourbot_sdk.events import MessageCreate

@plugin.on_event("message_create")
def log(ctx: Context, event: MessageCreate):
    if event.get("author_bot"):
        return
    log_channel = ctx.kv.get("mod_log_channel_id")
    if not log_channel:
        return
    text = event.get("content", "")[:200]
    ctx.discord.send_message(channel_id=str(log_channel),
        content=f"[#{event.get('channel_name', '?')}] <@{event['author_id']}>: {text}")
YourBot docs Reference tables are generated from the code that is running. Ask in Discord Suggest a correction