Fixed SO in RestChannel.Create

This commit is contained in:
RogueException
2016-10-08 18:26:02 -03:00
parent 09495e6d58
commit 8b24b01718
2 changed files with 33 additions and 18 deletions

View File

@@ -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;

View File

@@ -72,22 +72,6 @@ namespace Discord.Rest
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
//IGuildChannel
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetUserAsync(id, options).ConfigureAwait(false);
else
return null;
}
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return GetUsersAsync(options);
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); //Overriden
}
//IMessageChannel
async Task<IMessage> 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<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetUserAsync(id, options).ConfigureAwait(false);
else
return null;
}
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return GetUsersAsync(options);
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>();
}
//IChannel
async Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetUserAsync(id, options).ConfigureAwait(false);
else
return null;
}
IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return GetUsersAsync(options);
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>();
}
}
}