From 57c060fa2fccfbb3b3d4b2d18aad2faa5929deb3 Mon Sep 17 00:00:00 2001 From: Austin Hellyer Date: Fri, 2 Dec 2016 13:57:49 -0800 Subject: Paginate rest::get_guilds and add helper methods Paginate the rest::get_guilds endpoint, which can be used to retrieve the guilds after-or-before a certain guild's Id, with a limit of results to return (100 is the max). Example usage: ```rs use serenity::client::rest::GuildPagination; let target = GuildPagination::After(GuildId(81384788765712384)); let guilds = context.get_guilds(target, 50); ``` Additionally, add a method of `CurrentUser::guilds()`, to retrieve the current user's guilds. A limit of 100 is set, as (most) users can not be in more than 100 guilds. --- src/model/user.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/model') diff --git a/src/model/user.rs b/src/model/user.rs index d7ea416..88a6f9d 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -5,11 +5,13 @@ use super::{ FriendSourceFlags, GuildContainer, GuildId, + GuildInfo, Mention, RoleId, UserSettings, User, }; +use ::client::rest::GuildPagination; use ::internal::prelude::*; use ::utils::decode_array; @@ -31,6 +33,11 @@ impl CurrentUser { self.avatar.as_ref().map(|av| format!(cdn!("/avatars/{}/{}.jpg"), self.id, av)) } + + /// Gets a list of guilds that the current user is in. + pub fn guilds(&self) -> Result> { + rest::get_guilds(GuildPagination::After(GuildId(0)), 100) + } } impl User { -- cgit v1.2.3