Skip to content

Discord Provider

DiscordBotProvider

DiscordBotProvider(source)

Bases: DiscordProvider

Outbound Discord delivery via a shared gateway source.

The provider delegates every send to the discord.Client owned by the paired :class:~roomkit.sources.discord.DiscordGatewaySource. It does not manage the client lifecycle — that stays with the source.

send async

send(event, to)

Send event to Discord channel to (a channel snowflake).

DiscordConfig

Bases: BaseModel

Discord bot configuration.

The message_content intent is a privileged gateway intent: it must be enabled in the Discord Developer Portal (Bot → Privileged Gateway Intents) or every inbound message.content arrives empty.

MockDiscordProvider

MockDiscordProvider()

Bases: DiscordProvider

Records sent messages and reactions for verification in tests.

Carries no discord dependency and no gateway client, so it can drive the delivery path without a live connection.

DiscordGatewaySource

DiscordGatewaySource(config, channel_id='discord', *, parser=None, on_event=None)

Bases: BaseSourceProvider

Persistent Discord gateway connection emitting inbound messages.

Owns the discord.Client and exposes it via :attr:client so the paired provider can send through the same connection. Reactions are surfaced to on_event (not the message pipeline), matching how Teams and WhatsApp-personal handle reaction lifecycle events.

client property

client

Expose the underlying discord client for outbound use.

stop async

stop()

Disconnect from the Discord gateway and stop receiving.

parse_discord_message

parse_discord_message(message, channel_id, *, bot_user_id=None, ignore_bots=True)

Convert a discord.Message into an :class:InboundMessage.

Duck-typed (uses getattr) so it can be unit-tested with a plain stub object — no discord instance required. Returns None to skip the bot's own messages, other bots (when ignore_bots), and empty messages.