Integration testing

How do you test a Discord agent before production?

Short answer

Use a private Discord test server, then test the parts that silently disable bots: gateway intents, channel and role permissions, and event handling. A bot with the wrong intents receives no events at all and looks broken for no obvious reason.

Start with the official test environment

Create a private Discord server for testing and add your bot with the exact intents and permissions it will have in production. The Discord Developer Portal covers the intents and permission model, which is strict enough that getting it right locally saves confusing failures later.

Where agents actually break

The happy path is the easy part. An agent that can do the simple version of the task will still fall over on the cases below, and these are the ones worth building tests around:

  • Missing gateway intents, so the bot never receives the events it waits for
  • A channel permission that blocks the bot from posting where it expects to
  • A role hierarchy that stops the bot from acting on a higher-ranked member
  • Rate limits on rapid messages or reactions
  • Slash command registration that lags behind, so commands appear missing

How to test it properly

Give the agent a realistic starting state, let it run the full task end to end, then check the state it left behind rather than the response it returned. Run the same scenario twice to confirm it does not duplicate work or corrupt state on a retry. Then deliberately inject a failure partway through, a rejected write or a rate limit, and confirm the agent recovers instead of charging ahead as if nothing happened.