serenity icon indicating copy to clipboard operation
serenity copied to clipboard

Add with_expiration parameter to the invite_optioned route

Open xcf-t opened this issue 3 years ago • 2 comments
trafficstars

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.

xcf-t avatar Feb 04 '22 10:02 xcf-t

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).

AnnikaCodes avatar Feb 28 '22 06:02 AnnikaCodes

Implemented in #1757, can now be closed

kangalio avatar Sep 12 '22 08:09 kangalio