public static Task <IReadOnlyList <IPartialGuild> > FetchGuildsAsync(this IRestClient client, int limit = 100, RetrievalDirection direction = RetrievalDirection.Before, Snowflake?startFromId = null, IRestRequestOptions options = null) { if (limit == 0) { return(Task.FromResult(ReadOnlyList <IPartialGuild> .Empty)); } if (limit <= 100) { return(client.InternalFetchGuildsAsync(limit, direction, startFromId, options)); } var enumerable = client.EnumerateGuilds(limit, direction, startFromId, options); return(enumerable.FlattenAsync()); }
public static Task <IReadOnlyList <IPartialGuild> > FetchGuildsAsync(this IRestClient client, int limit = Discord.Limits.Rest.FetchGuildsPageSize, RetrievalDirection direction = RetrievalDirection.After, Snowflake?startFromId = null, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { Guard.IsGreaterThanOrEqualTo(limit, 0); if (limit == 0) { return(Task.FromResult(ReadOnlyList <IPartialGuild> .Empty)); } if (limit <= Discord.Limits.Rest.FetchGuildsPageSize) { return(client.InternalFetchGuildsAsync(limit, direction, startFromId, options, cancellationToken)); } var enumerable = client.EnumerateGuilds(limit, direction, startFromId, options); return(enumerable.FlattenAsync(cancellationToken)); }