From 8b24b01718ca21a18fd861c9b7aaa165d284e044 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sat, 8 Oct 2016 18:26:02 -0300 Subject: [PATCH] Fixed SO in RestChannel.Create --- .../Entities/Channels/RestChannel.cs | 3 +- .../Entities/Channels/RestTextChannel.cs | 48 ++++++++++++------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs index 342dd6898..e2a98e282 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs @@ -17,9 +17,8 @@ namespace Discord.Rest switch (model.Type) { case ChannelType.Text: - return RestTextChannel.Create(discord, model); case ChannelType.Voice: - return RestVoiceChannel.Create(discord, model); + return RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model); case ChannelType.DM: case ChannelType.Group: return CreatePrivate(discord, model) as RestChannel; diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index d8fc6637a..35ba91f02 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -72,22 +72,6 @@ namespace Discord.Rest private string DebuggerDisplay => $"{Name} ({Id}, Text)"; - //IGuildChannel - async Task IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) - { - if (mode == CacheMode.AllowDownload) - return await GetUserAsync(id, options).ConfigureAwait(false); - else - return null; - } - IAsyncEnumerable> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) - { - if (mode == CacheMode.AllowDownload) - return GetUsersAsync(options); - else - return AsyncEnumerable.Empty>(); //Overriden - } - //IMessageChannel async Task IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) { @@ -128,5 +112,37 @@ namespace Discord.Rest => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); + + //IGuildChannel + async Task IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) + { + if (mode == CacheMode.AllowDownload) + return await GetUserAsync(id, options).ConfigureAwait(false); + else + return null; + } + IAsyncEnumerable> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) + { + if (mode == CacheMode.AllowDownload) + return GetUsersAsync(options); + else + return AsyncEnumerable.Empty>(); + } + + //IChannel + async Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) + { + if (mode == CacheMode.AllowDownload) + return await GetUserAsync(id, options).ConfigureAwait(false); + else + return null; + } + IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) + { + if (mode == CacheMode.AllowDownload) + return GetUsersAsync(options); + else + return AsyncEnumerable.Empty>(); + } } }