Context
Follow-up from PR #583 review. The SenderContext assembly logic is currently embedded inside EventHandler::message() in src/discord.rs, making it difficult to unit test without mocking serenity.
Proposal
Extract a pure function build_sender_context() that takes the resolved values (in_thread, parent_id, msg_channel_id, author info, etc.) and returns a SenderContext. This enables table-driven tests covering:
- in-thread message →
channel_id = parent, thread_id = Some(thread)
- non-thread message →
channel_id = channel, thread_id = None
- error/non-guild fallback →
channel_id = channel, thread_id = None
Similar to how detect_thread() was already extracted as a pure function.
References
Context
Follow-up from PR #583 review. The
SenderContextassembly logic is currently embedded insideEventHandler::message()insrc/discord.rs, making it difficult to unit test without mocking serenity.Proposal
Extract a pure function
build_sender_context()that takes the resolved values (in_thread, parent_id, msg_channel_id, author info, etc.) and returns aSenderContext. This enables table-driven tests covering:channel_id= parent,thread_id= Some(thread)channel_id= channel,thread_id= Nonechannel_id= channel,thread_id= NoneSimilar to how
detect_thread()was already extracted as a pure function.References