Fixed SO in RestChannel.Create
This commit is contained in:
@@ -17,9 +17,8 @@ namespace Discord.Rest
|
|||||||
switch (model.Type)
|
switch (model.Type)
|
||||||
{
|
{
|
||||||
case ChannelType.Text:
|
case ChannelType.Text:
|
||||||
return RestTextChannel.Create(discord, model);
|
|
||||||
case ChannelType.Voice:
|
case ChannelType.Voice:
|
||||||
return RestVoiceChannel.Create(discord, model);
|
return RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model);
|
||||||
case ChannelType.DM:
|
case ChannelType.DM:
|
||||||
case ChannelType.Group:
|
case ChannelType.Group:
|
||||||
return CreatePrivate(discord, model) as RestChannel;
|
return CreatePrivate(discord, model) as RestChannel;
|
||||||
|
|||||||
@@ -72,22 +72,6 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
|
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
|
//IMessageChannel
|
||||||
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
|
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);
|
=> await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
|
||||||
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
|
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
|
||||||
=> EnterTypingState(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>>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user