| @@ -13,7 +13,7 @@ namespace Discord.Commands | |||
| public override async Task<TypeReaderResult> Read(ICommandContext context, string input) | |||
| { | |||
| var results = new Dictionary<ulong, TypeReaderValue>(); | |||
| IReadOnlyCollection<IUser> channelUsers = (await context.Channel.GetUsersAsync(CacheMode.CacheOnly).Flatten().ConfigureAwait(false)).ToArray(); //TODO: must be a better way? | |||
| IReadOnlyCollection<IUser> channelUsers = await context.Channel.GetUsersAsync(CacheMode.CacheOnly).ToArray().ConfigureAwait(false); //TODO: must be a better way? | |||
| IReadOnlyCollection<IGuildUser> guildUsers = ImmutableArray.Create<IGuildUser>(); | |||
| ulong id; | |||
| @@ -12,7 +12,7 @@ namespace Discord | |||
| bool IsNsfw { get; } | |||
| /// <summary> Gets a collection of all users in this channel. </summary> | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| IAsyncEnumerable<IUser> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| /// <summary> Gets a user in this channel with the provided id. </summary> | |||
| Task<IUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| @@ -41,7 +41,7 @@ namespace Discord | |||
| Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null); | |||
| /// <summary> Gets a collection of all users in this channel. </summary> | |||
| new IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| new IAsyncEnumerable<IGuildUser> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| /// <summary> Gets a user in this channel with the provided id.</summary> | |||
| new Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| } | |||
| @@ -19,13 +19,13 @@ namespace Discord | |||
| /// <summary> Gets a message from this message channel with the given id, or null if not found. </summary> | |||
| Task<IMessage> GetMessageAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| /// <summary> Gets the last N messages from this message channel. </summary> | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, | |||
| IAsyncEnumerable<IMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, | |||
| CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| /// <summary> Gets a collection of messages in this channel. </summary> | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, | |||
| IAsyncEnumerable<IMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, | |||
| CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| /// <summary> Gets a collection of messages in this channel. </summary> | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, | |||
| IAsyncEnumerable<IMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, | |||
| CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
| /// <summary> Gets a collection of pinned messages in this channel. </summary> | |||
| Task<IReadOnlyCollection<IMessage>> GetPinnedMessagesAsync(RequestOptions options = null); | |||
| @@ -1,14 +0,0 @@ | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public static class AsyncEnumerableExtensions | |||
| { | |||
| public static async Task<IEnumerable<T>> Flatten<T>(this IAsyncEnumerable<IReadOnlyCollection<T>> source) | |||
| { | |||
| return (await source.ToArray().ConfigureAwait(false)).SelectMany(x => x); | |||
| } | |||
| } | |||
| } | |||
| @@ -5,7 +5,7 @@ using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| internal class PagedAsyncEnumerable<T> : IAsyncEnumerable<IReadOnlyCollection<T>> | |||
| internal class PagedAsyncEnumerable<T> : IAsyncEnumerable<T> | |||
| { | |||
| public int PageSize { get; } | |||
| @@ -25,13 +25,15 @@ namespace Discord | |||
| _nextPage = nextPage; | |||
| } | |||
| public IAsyncEnumerator<IReadOnlyCollection<T>> GetEnumerator() => new Enumerator(this); | |||
| internal class Enumerator : IAsyncEnumerator<IReadOnlyCollection<T>> | |||
| public IAsyncEnumerator<T> GetEnumerator() => new Enumerator(this); | |||
| internal class Enumerator : IAsyncEnumerator<T> | |||
| { | |||
| private readonly PagedAsyncEnumerable<T> _source; | |||
| private readonly PageInfo _info; | |||
| private IReadOnlyCollection<T> _currentPage; | |||
| private IEnumerator<T> _currentPageEnumerator; | |||
| public IReadOnlyCollection<T> Current { get; private set; } | |||
| public T Current => _currentPageEnumerator.Current; | |||
| public Enumerator(PagedAsyncEnumerable<T> source) | |||
| { | |||
| @@ -44,34 +46,43 @@ namespace Discord | |||
| if (_info.Remaining == 0) | |||
| return false; | |||
| var data = await _source._getPage(_info, cancelToken).ConfigureAwait(false); | |||
| Current = new Page<T>(_info, data); | |||
| _info.Page++; | |||
| if (_info.Remaining != null) | |||
| if (_currentPage == null || _currentPageEnumerator == null || !_currentPageEnumerator.MoveNext()) | |||
| { | |||
| if (Current.Count >= _info.Remaining) | |||
| _info.Remaining = 0; | |||
| _currentPageEnumerator?.Dispose(); | |||
| var data = await _source._getPage(_info, cancelToken).ConfigureAwait(false); | |||
| _currentPage = new Page<T>(_info, data); | |||
| _currentPageEnumerator = _currentPage.GetEnumerator(); | |||
| _info.Page++; | |||
| if (_info.Remaining != null) | |||
| { | |||
| if (_currentPage.Count >= _info.Remaining) | |||
| _info.Remaining = 0; | |||
| else | |||
| _info.Remaining -= _currentPage.Count; | |||
| } | |||
| else | |||
| _info.Remaining -= Current.Count; | |||
| } | |||
| else | |||
| { | |||
| if (Current.Count == 0) | |||
| _info.Remaining = 0; | |||
| } | |||
| _info.PageSize = _info.Remaining != null ? (int)Math.Min(_info.Remaining.Value, _source.PageSize) : _source.PageSize; | |||
| { | |||
| if (_currentPage.Count == 0) | |||
| _info.Remaining = 0; | |||
| } | |||
| _info.PageSize = _info.Remaining != null ? Math.Min(_info.Remaining.Value, _source.PageSize) : _source.PageSize; | |||
| if (_info.Remaining != 0) | |||
| { | |||
| if (!_source._nextPage(_info, data)) | |||
| _info.Remaining = 0; | |||
| if (_info.Remaining != 0) | |||
| { | |||
| if (!_source._nextPage(_info, data)) | |||
| _info.Remaining = 0; | |||
| } | |||
| } | |||
| return true; | |||
| } | |||
| public void Dispose() { Current = null; } | |||
| public void Dispose() | |||
| { | |||
| _currentPageEnumerator.Dispose(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -75,7 +75,7 @@ namespace Discord.Rest | |||
| return RestGuildEmbed.Create(model); | |||
| return null; | |||
| } | |||
| public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client, | |||
| public static IAsyncEnumerable<RestUserGuild> GetGuildSummariesAsync(BaseDiscordClient client, | |||
| ulong? fromGuildId, int? limit, RequestOptions options) | |||
| { | |||
| return new PagedAsyncEnumerable<RestUserGuild>( | |||
| @@ -106,7 +106,7 @@ namespace Discord.Rest | |||
| } | |||
| public static async Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(BaseDiscordClient client, RequestOptions options) | |||
| { | |||
| var summaryModels = await GetGuildSummariesAsync(client, null, null, options).Flatten(); | |||
| var summaryModels = GetGuildSummariesAsync(client, null, null, options).ToEnumerable(); | |||
| var guilds = ImmutableArray.CreateBuilder<RestGuild>(); | |||
| foreach (var summaryModel in summaryModels) | |||
| { | |||
| @@ -66,10 +66,10 @@ namespace Discord.Rest | |||
| public Task<RestGuildEmbed?> GetGuildEmbedAsync(ulong id, RequestOptions options = null) | |||
| => ClientHelper.GetGuildEmbedAsync(this, id, options); | |||
| /// <inheritdoc /> | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null) | |||
| public IAsyncEnumerable<RestUserGuild> GetGuildSummariesAsync(RequestOptions options = null) | |||
| => ClientHelper.GetGuildSummariesAsync(this, null, null, options); | |||
| /// <inheritdoc /> | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestUserGuild> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null) | |||
| => ClientHelper.GetGuildSummariesAsync(this, fromGuildId, limit, options); | |||
| /// <inheritdoc /> | |||
| public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null) | |||
| @@ -96,7 +96,7 @@ namespace Discord.Rest | |||
| var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); | |||
| return RestMessage.Create(client, channel, author, model); | |||
| } | |||
| public static IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessageChannel channel, BaseDiscordClient client, | |||
| public static IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessageChannel channel, BaseDiscordClient client, | |||
| ulong? fromMessageId, Direction dir, int limit, RequestOptions options) | |||
| { | |||
| if (dir == Direction.Around) | |||
| @@ -238,7 +238,7 @@ namespace Discord.Rest | |||
| return user; | |||
| } | |||
| public static IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client, | |||
| public static IAsyncEnumerable<RestGuildUser> GetUsersAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client, | |||
| ulong? fromUserId, int? limit, RequestOptions options) | |||
| { | |||
| return new PagedAsyncEnumerable<RestGuildUser>( | |||
| @@ -18,11 +18,11 @@ namespace Discord.Rest | |||
| /// <summary> Gets a message from this message channel with the given id, or null if not found. </summary> | |||
| Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null); | |||
| /// <summary> Gets the last N messages from this message channel. </summary> | |||
| IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null); | |||
| IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null); | |||
| /// <summary> Gets a collection of messages in this channel. </summary> | |||
| IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null); | |||
| IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null); | |||
| /// <summary> Gets a collection of messages in this channel. </summary> | |||
| IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null); | |||
| IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null); | |||
| /// <summary> Gets a collection of pinned messages in this channel. </summary> | |||
| new Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null); | |||
| } | |||
| @@ -50,7 +50,7 @@ namespace Discord.Rest | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(null); //Overriden | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IReadOnlyCollection<IUser>>(); //Overriden | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IUser>(); //Overriden | |||
| } | |||
| } | |||
| @@ -54,11 +54,11 @@ namespace Discord.Rest | |||
| public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
| @@ -100,26 +100,26 @@ namespace Discord.Rest | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessageId, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessage, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -140,7 +140,7 @@ namespace Discord.Rest | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(GetUser(id)); | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IUser>>(Users).ToAsyncEnumerable(); | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IUser>(Users.ToArray()).ToAsyncEnumerable(); | |||
| } | |||
| } | |||
| @@ -67,11 +67,11 @@ namespace Discord.Rest | |||
| public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
| @@ -110,26 +110,26 @@ namespace Discord.Rest | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessageId, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessage, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -151,7 +151,7 @@ namespace Discord.Rest | |||
| //IChannel | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(GetUser(id)); | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IUser>>(Users).ToAsyncEnumerable(); | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IUser>(Users.ToArray()).ToAsyncEnumerable(); | |||
| } | |||
| } | |||
| @@ -152,14 +152,14 @@ namespace Discord.Rest | |||
| async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options) | |||
| => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false); | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); //Overriden //Overriden in Text/Voice | |||
| IAsyncEnumerable<IGuildUser> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IGuildUser>(); //Overriden //Overriden in Text/Voice | |||
| Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IGuildUser>(null); //Overriden in Text/Voice | |||
| //IChannel | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IReadOnlyCollection<IUser>>(); //Overriden in Text/Voice | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IUser>(); //Overriden in Text/Voice | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(null); //Overriden in Text/Voice | |||
| } | |||
| @@ -40,16 +40,16 @@ namespace Discord.Rest | |||
| public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetUserAsync(this, Guild, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null) | |||
| public IAsyncEnumerable<RestGuildUser> GetUsersAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options); | |||
| public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
| @@ -81,26 +81,26 @@ namespace Discord.Rest | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessageId, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessage, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -124,12 +124,12 @@ namespace Discord.Rest | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IGuildUser> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetUsersAsync(options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); | |||
| return AsyncEnumerable.Empty<IGuildUser>(); | |||
| } | |||
| //IChannel | |||
| @@ -140,12 +140,12 @@ namespace Discord.Rest | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetUsersAsync(options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); | |||
| return AsyncEnumerable.Empty<IGuildUser>(); | |||
| } | |||
| } | |||
| } | |||
| @@ -46,7 +46,7 @@ namespace Discord.Rest | |||
| //IGuildChannel | |||
| Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IGuildUser>(null); | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); | |||
| IAsyncEnumerable<IGuildUser> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IGuildUser>(); | |||
| } | |||
| } | |||
| @@ -24,11 +24,11 @@ namespace Discord.Rest | |||
| public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
| @@ -60,26 +60,26 @@ namespace Discord.Rest | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessageId, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessage, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options); | |||
| @@ -98,7 +98,7 @@ namespace Discord.Rest | |||
| //IChannel | |||
| string IChannel.Name { get { throw new NotSupportedException(); } } | |||
| bool IChannel.IsNsfw { get { throw new NotSupportedException(); } } | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| @@ -209,7 +209,7 @@ namespace Discord.Rest | |||
| { | |||
| return await GetUserAsync(guild, client, client.CurrentUser.Id, options).ConfigureAwait(false); | |||
| } | |||
| public static IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(IGuild guild, BaseDiscordClient client, | |||
| public static IAsyncEnumerable<RestGuildUser> GetUsersAsync(IGuild guild, BaseDiscordClient client, | |||
| ulong? fromUserId, int? limit, RequestOptions options) | |||
| { | |||
| return new PagedAsyncEnumerable<RestGuildUser>( | |||
| @@ -227,7 +227,7 @@ namespace Discord.Rest | |||
| } | |||
| //Users | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null) | |||
| public IAsyncEnumerable<RestGuildUser> GetUsersAsync(RequestOptions options = null) | |||
| => GuildHelper.GetUsersAsync(this, Discord, null, null, options); | |||
| public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null) | |||
| => GuildHelper.GetUserAsync(this, Discord, id, options); | |||
| @@ -356,7 +356,7 @@ namespace Discord.Rest | |||
| async Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return (await GetUsersAsync(options).Flatten().ConfigureAwait(false)).ToImmutableArray(); | |||
| return (await GetUsersAsync(options).ToArray().ConfigureAwait(false)).ToImmutableArray(); | |||
| else | |||
| return ImmutableArray.Create<IGuildUser>(); | |||
| } | |||
| @@ -35,11 +35,11 @@ namespace Discord.Rpc | |||
| //TODO: Use RPC cache | |||
| public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
| @@ -78,26 +78,26 @@ namespace Discord.Rpc | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessageId, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessage, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -120,7 +120,7 @@ namespace Discord.Rpc | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| @@ -38,11 +38,11 @@ namespace Discord.Rpc | |||
| //TODO: Use RPC cache | |||
| public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
| @@ -78,26 +78,26 @@ namespace Discord.Rpc | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessageId, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessage, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -123,7 +123,7 @@ namespace Discord.Rpc | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| @@ -80,7 +80,7 @@ namespace Discord.Rpc | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IGuildUser> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| @@ -90,7 +90,7 @@ namespace Discord.Rpc | |||
| } | |||
| //IChannel | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| throw new NotSupportedException(); | |||
| } | |||
| @@ -39,11 +39,11 @@ namespace Discord.Rpc | |||
| //TODO: Use RPC cache | |||
| public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
| => ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<RestMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
| @@ -78,26 +78,26 @@ namespace Discord.Rpc | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessageId, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(fromMessage, dir, limit, options); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| } | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -45,7 +45,7 @@ namespace Discord.WebSocket | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(null); //Overridden | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IReadOnlyCollection<IUser>>(); //Overridden | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IUser>(); //Overridden | |||
| } | |||
| } | |||
| @@ -8,17 +8,17 @@ namespace Discord.WebSocket | |||
| { | |||
| internal static class SocketChannelHelper | |||
| { | |||
| public static IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ISocketMessageChannel channel, DiscordSocketClient discord, MessageCache messages, | |||
| public static IAsyncEnumerable<IMessage> GetMessagesAsync(ISocketMessageChannel channel, DiscordSocketClient discord, MessageCache messages, | |||
| ulong? fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (dir == Direction.Around) | |||
| throw new NotImplementedException(); //TODO: Impl | |||
| IReadOnlyCollection<SocketMessage> cachedMessages = null; | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> result = null; | |||
| IAsyncEnumerable<IMessage> result = null; | |||
| if (dir == Direction.After && fromMessageId == null) | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| return AsyncEnumerable.Empty<IMessage>(); | |||
| if (dir == Direction.Before || mode == CacheMode.CacheOnly) | |||
| { | |||
| @@ -26,7 +26,7 @@ namespace Discord.WebSocket | |||
| cachedMessages = messages.GetMany(fromMessageId, dir, limit); | |||
| else | |||
| cachedMessages = ImmutableArray.Create<SocketMessage>(); | |||
| result = ImmutableArray.Create(cachedMessages).ToAsyncEnumerable<IReadOnlyCollection<IMessage>>(); | |||
| result = ImmutableArray.Create(cachedMessages.ToArray()).ToAsyncEnumerable<IMessage>(); | |||
| } | |||
| if (dir == Direction.Before) | |||
| @@ -52,11 +52,11 @@ namespace Discord.WebSocket | |||
| msg = await ChannelHelper.GetMessageAsync(this, Discord, id, options).ConfigureAwait(false); | |||
| return msg; | |||
| } | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | |||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, null, Direction.Before, limit); | |||
| @@ -125,11 +125,11 @@ namespace Discord.WebSocket | |||
| else | |||
| return GetCachedMessage(id); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, mode, options); | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, mode, options); | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -149,7 +149,7 @@ namespace Discord.WebSocket | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(GetUser(id)); | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IUser>>(Users).ToAsyncEnumerable(); | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IUser>(Users.ToArray()).ToAsyncEnumerable(); | |||
| } | |||
| } | |||
| @@ -80,11 +80,11 @@ namespace Discord.WebSocket | |||
| msg = await ChannelHelper.GetMessageAsync(this, Discord, id, options).ConfigureAwait(false); | |||
| return msg; | |||
| } | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | |||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, null, Direction.Before, limit); | |||
| @@ -189,11 +189,11 @@ namespace Discord.WebSocket | |||
| else | |||
| return GetCachedMessage(id); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, mode, options); | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, mode, options); | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -214,7 +214,7 @@ namespace Discord.WebSocket | |||
| //IChannel | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(GetUser(id)); | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IUser>>(Users).ToAsyncEnumerable(); | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IUser>(Users.ToArray()).ToAsyncEnumerable(); | |||
| } | |||
| } | |||
| @@ -146,14 +146,14 @@ namespace Discord.WebSocket | |||
| async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options) | |||
| => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false); | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); | |||
| IAsyncEnumerable<IGuildUser> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IGuildUser>(Users.ToArray()).ToAsyncEnumerable(); | |||
| Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IGuildUser>(GetUser(id)); | |||
| //IChannel | |||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IUser>>(Users).ToAsyncEnumerable(); //Overriden in Text/Voice | |||
| IAsyncEnumerable<IUser> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IUser>(Users.ToArray()).ToAsyncEnumerable(); //Overriden in Text/Voice | |||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IUser>(GetUser(id)); //Overriden in Text/Voice | |||
| } | |||
| @@ -56,11 +56,11 @@ namespace Discord.WebSocket | |||
| msg = await ChannelHelper.GetMessageAsync(this, Discord, id, options).ConfigureAwait(false); | |||
| return msg; | |||
| } | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| public IAsyncEnumerable<IMessage> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | |||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, null, Direction.Before, limit); | |||
| @@ -113,8 +113,8 @@ namespace Discord.WebSocket | |||
| //IGuildChannel | |||
| Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IGuildUser>(GetUser(id)); | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); | |||
| IAsyncEnumerable<IGuildUser> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IGuildUser>(Users.ToArray()).ToAsyncEnumerable(); | |||
| //IMessageChannel | |||
| async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| @@ -124,11 +124,11 @@ namespace Discord.WebSocket | |||
| else | |||
| return GetCachedMessage(id); | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, mode, options); | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, mode, options); | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| IAsyncEnumerable<IMessage> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| @@ -59,7 +59,7 @@ namespace Discord.WebSocket | |||
| //IGuildChannel | |||
| Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IGuildUser>(GetUser(id)); | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); | |||
| IAsyncEnumerable<IGuildUser> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IGuildUser>(Users.ToArray()).ToAsyncEnumerable(); | |||
| } | |||
| } | |||