Bot tokens, intents and the three limiter scopes
Connection runs through a bot token from Discord’s developer portal, with per-channel permissions decided by server roles and privileged gateway intents toggled on explicitly; message content is one of them.
Discord rate-limits in layers: per-route buckets, optionally shared across similar endpoints and scoped per top-level resource (channel, guild or webhook), plus a global limit over the bot’s total traffic. The X-RateLimit-Bucket header identifies which bucket a route belongs to.
A 429 carries retry_after in the body and an X-RateLimit-Scope header: user for the per-route limit, global for the bot-wide one, shared for resource limits that do not count against the bot. Well-behaved runs read the rate-limit headers on every response and stop sending on an exhausted bucket before the 429 happens.
A posted message is real content in the user’s server. Keep a run safe to re-execute: scan for its marker first, record the message id it posted, and never delete messages to hide a duplicate created by a retry.
Sources: Message resource, Channel resource, Rate limits.