Skip to content

Conversation

DPlayer234
Copy link
Contributor

@DPlayer234 DPlayer234 commented Oct 11, 2025

Rather than having the ClientBuilder accept impl Into<Arc<H>> where H: HandlerTrait, directly accept the corresponding Arc<dyn HandlerTrait>.
This allows accepting non-concrete handler types (f.e. if constructed by a function that returns Arc<dyn HandlerTrait> already) and fixes type inference failures when passing an Arc<H> rather than H.

This affects the setters for EventHandler, RawEventHandler, Framework, and VoiceGatewayManager.

Framework is in a bit of a weird spot because it is only put in an Arc after Framework::init has been called, so a &mut can be taken to it for that call, so this PR has ClientBuilder accept Box<dyn Framework> for it.

Most of the PR diff is related to fixing examples.

@github-actions github-actions bot added gateway Related to the `gateway` module. examples Related to Serenity's examples. labels Oct 11, 2025
@Joshix-1
Copy link

the readme mentions the event_handler method. You should update that and check if there are other markdown files mentioning the methods you changed

@DPlayer234
Copy link
Contributor Author

The example in the README was horribly outdated, I've replaced it with a trimmed down version of the up-to-date ping bot example.
Didn't find any other places where these functions are used in non-Rust files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Related to Serenity's examples. gateway Related to the `gateway` module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants