Tutorials

Channel Automation

Add a safer channel override to an onMessage server automation.

Published by solever7 solever7
tutorial events onMessage channel

onMessage watches every user-authored message. It can occupy the server slot, while an
optional channel-owned script overrides that behavior in one exact channel. Prefer a
channel override for high-frequency or destructive behavior: its cost and effects are
easier to review and contain.

Start With A Harmless Script

Run /new, choose onMessage, choose Channel, and create it in a test channel with
this source:

if ctx.message and ctx.message.text == "hello" then
  macchi.reply("Hello from this channel.")
end

Keep it inactive while reviewing the source. Activate it from the script panel, send
hello in the selected channel, then try another channel. The selected channel resolves
the override; without an active server-wide onMessage, other channels resolve nothing.

Understand The Context

ctx.channel, ctx.guild, and ctx.message identify the validated event. ctx.user and
ctx.member describe the message author, but the author does not lend Discord
permissions to automatic code. The active configuration provides Server authority
whether its owner is the server or the exact channel. Every host action still checks
capabilities, bot permissions, hierarchy, scope, and per-run limits.

Install The Honeypot Safely

The public u0/honeypot@2 seed is deliberately destructive. Use a dedicated existing
channel, review the exact source and requested capabilities, make sure administrators
and channel managers are exempt, then enable the installation. Never use it in a normal
conversation channel.

Macchi caches the event lookup briefly and invalidates it when script state changes. The
bot still rechecks the returned trigger, guild, and typed owner before each run. A
channel override must also match the current channel exactly.

Continue

Read Events for other triggers or Safety before
granting moderation and storage capabilities.