Create unspecified channel object for unknown channel types (#811)
* Partial fix of #810, addresses critical connection issues. * Implement fix for REST. * Implement fix on RestChannel.
This commit is contained in:
committed by
Finite Reality
parent
479361bbea
commit
ec03883e26
@@ -6,7 +6,7 @@ using Model = Discord.API.Channel;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
public abstract class RestChannel : RestEntity<ulong>, IChannel, IUpdateable
|
||||
public class RestChannel : RestEntity<ulong>, IChannel, IUpdateable
|
||||
{
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Discord.Rest
|
||||
case ChannelType.Group:
|
||||
return CreatePrivate(discord, model) as RestChannel;
|
||||
default:
|
||||
throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
|
||||
return new RestChannel(discord, model.Id);
|
||||
}
|
||||
}
|
||||
internal static IRestPrivateChannel CreatePrivate(BaseDiscordClient discord, Model model)
|
||||
@@ -40,9 +40,9 @@ namespace Discord.Rest
|
||||
throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
|
||||
}
|
||||
}
|
||||
internal abstract void Update(Model model);
|
||||
internal virtual void Update(Model model) { }
|
||||
|
||||
public abstract Task UpdateAsync(RequestOptions options = null);
|
||||
public virtual Task UpdateAsync(RequestOptions options = null) => Task.Delay(0);
|
||||
|
||||
//IChannel
|
||||
string IChannel.Name => null;
|
||||
|
||||
@@ -7,7 +7,7 @@ using Model = Discord.API.Channel;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
public abstract class RestGuildChannel : RestChannel, IGuildChannel, IUpdateable
|
||||
public class RestGuildChannel : RestChannel, IGuildChannel, IUpdateable
|
||||
{
|
||||
private ImmutableArray<Overwrite> _overwrites;
|
||||
|
||||
@@ -33,7 +33,8 @@ namespace Discord.Rest
|
||||
case ChannelType.Voice:
|
||||
return RestVoiceChannel.Create(discord, guild, model);
|
||||
default:
|
||||
throw new InvalidOperationException("Unknown guild channel type");
|
||||
// TODO: Channel categories
|
||||
return new RestGuildChannel(discord, guild, model.Id);
|
||||
}
|
||||
}
|
||||
internal override void Update(Model model)
|
||||
|
||||
Reference in New Issue
Block a user