Skip to content

Discord: initialize DiscordAdapter in ready() instead of OnceLock on first message #387

@thepagent

Description

@thepagent

Parent: #382

Problem

discord::Handler stores adapter: OnceLock<Arc<dyn ChatAdapter>> and initializes it lazily on the first message() event via get_or_init(). This works but is slightly fragile — if ready() fires but no message ever arrives, the adapter is never created.

Suggested fix

Initialize the DiscordAdapter in the ready() handler where ctx.http is already available. This provides a cleaner lifecycle and guarantees the adapter exists as soon as the bot is connected.

Severity: nit — no functional impact, purely code hygiene.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions