Lesson 5 of 9 · 21m
Privileged Intents, Event Access, and Data Minimization
Choose gateway intents deliberately, justify privileged access, and design caches that collect only the data enforcement truly needs.
Privileged intents are where product convenience and platform trust collide. Discord is not asking what events your code wants for fun; it is asking what user behavior your bot needs to observe. Message content, server members, and presence are sensitive because they turn your bot from an invoked utility into a continuous observer. Treat that decision with the seriousness you would give log collection in any other product.
Intents are event subscriptions with consequences
A gateway identify declares intents. In broad terms:
Guilds guild/channel/role structure events
GuildMembers privileged member join/update events
GuildMessages message lifecycle events
MessageContent privileged access to message content
GuildPresences privileged presence updatesReceiving MESSAGE_CREATE is not the same as being allowed to inspect its content. Without the Message Content intent, content can be empty or unavailable except in specific cases such as direct mentions or interactions. This distinction breaks naive moderation bots after approval or migration.
Ask for the enforcement need, not the demo need
Write down the exact feature that requires each privileged intent:
join raid detection GuildMembers
invite/link/toxicity scan MessageContent
offline member sweep GuildMembers
status-aware features GuildPresences, rarely justifiedIf a feature only acts on slash commands, buttons, audit-log events, or messages mentioning the bot, you may not need broad message content. Native Discord AutoMod can also cover baseline content filtering without your bot storing message text at all.
Minimize what you retain
Event access and data retention are separate decisions. You may receive content to evaluate it, but you do not need to retain all content forever. A practical moderation pipeline is:
observe event -> extract features -> apply policy -> store decision evidence
-> discard raw contentStore hashes, excerpts, attachments metadata, author/channel/message IDs, rule identifiers, and action outcomes. If exact content is needed for appeal review, encrypt it, scope access tightly, and expire it deliberately.
Approval changes your scaling contract
Verified bots requesting privileged intents must justify them to Discord. That process is not merely paperwork. Approval means you have explicitly accepted a privacy and safety contract. If you later add features outside the approved purpose, you have product risk even when the code still works.
Build a degraded mode
Intent approval can lag deployment, a token can be recreated without the same entitlements, or a configuration mistake can strip content access. Detect the degraded mode explicitly:
if (message.content === "" && expectsContentScanning(message)) metrics.increment("moderation.content_unavailable");Do not silently stop scanning and call it uptime. Emit a metric, expose it in the dashboard, and fail closed only where the safety model demands it.
Field notes
- Message Content intent does not retroactively make old messages available; it governs what current events and fetches expose.
- Presence intent is rarely necessary for moderation and carries disproportionate privacy sensitivity.
- Cache eviction is not data minimization if your observability pipeline still logs the sensitive payload.
- Re-check intents after framework upgrades; library defaults and warnings can change.
Was this lesson helpful?