Skip to content

Refactor/Usability: Making more use of traits #3396

@TudbuT

Description

@TudbuT

At the moment, serenity has lots of similar structs that are fully separate from another, e.g. CreateMessage and CreateInteractionResponse. (Similar things apply for e.g. all the who-when-where stuff in e.g. CommandInteraction, Message, and ComponentInteraction.) These have very similar applications and very similar methods in them, but when making a bot that can respond both to messages, buttons, and commands, i had to adapt them using an enum. It would've been much nicer to just have a trait for this that is dyn-compatible.

For this to work however, the builders need to be changed to work with (&mut self, ...) -> () style functions instead of (self, ...) -> Self, as otherwise the dyn compatibility is lost. This pattern makes writing highly modular bots much easier in general.

Is this planned, or even possible to do given the existing code, or would this require a hard fork?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions