serenity
serenity copied to clipboard
Add with_expiration parameter to the invite_optioned route
The Discord API allows for a with_expiration? parameter in the /invites/{invite.code} endpoint which is currently missing in serenity.
https://discord.com/developers/docs/resources/invite#get-invite
https://github.com/serenity-rs/serenity/blob/48ca50627004afdb836b3c9ccb84bb92373eaa25/src/http/routing.rs#L825-L829
This could either be handled by setting both with_expiration and with_counts according to the stats-parameter or by adding a new parameter to configure both individually.
I'd like to work on this. I'm thinking of changing the function signature
async fn get_invite(&self, mut code: &str, stats: bool) -> Result<Invite>
to
async fn get_invite(&self, mut code: &str, member_count: bool, expiration: bool, event_id: Option<u64>) -> Result<Invite>
Does this look good?
We could also use an enum for configuration:
enum InviteOptions {
Plain,
WithMemberCount,
WithExpiration,
WithMemberCountAndExpiration,
}
async fn get_invite(&self, mut code: &str, options: InviteOptions, event_id: Option<u64>) -> Result<Invite>
but personally I think that's overkill (up to y'all though).
Implemented in #1757, can now be closed