Browse Source

Partial fix of #810, addresses critical connection issues.

pull/811/head
Alex Gravely 8 years ago
parent
commit
9be45e0ae3
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs

+ 7
- 6
src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs View File

@@ -10,7 +10,7 @@ using Model = Discord.API.Channel;
namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class SocketGuildChannel : SocketChannel, IGuildChannel
public class SocketGuildChannel : SocketChannel, IGuildChannel
{ {
private ImmutableArray<Overwrite> _overwrites; private ImmutableArray<Overwrite> _overwrites;


@@ -19,7 +19,7 @@ namespace Discord.WebSocket
public int Position { get; private set; } public int Position { get; private set; }


public IReadOnlyCollection<Overwrite> PermissionOverwrites => _overwrites; public IReadOnlyCollection<Overwrite> PermissionOverwrites => _overwrites;
public new abstract IReadOnlyCollection<SocketGuildUser> Users { get; }
public new virtual IReadOnlyCollection<SocketGuildUser> Users => ImmutableArray.Create<SocketGuildUser>();


internal SocketGuildChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) internal SocketGuildChannel(DiscordSocketClient discord, ulong id, SocketGuild guild)
: base(discord, id) : base(discord, id)
@@ -35,7 +35,8 @@ namespace Discord.WebSocket
case ChannelType.Voice: case ChannelType.Voice:
return SocketVoiceChannel.Create(guild, state, model); return SocketVoiceChannel.Create(guild, state, model);
default: default:
throw new InvalidOperationException("Unknown guild channel type");
// TODO: Proper implementation for channel categories
return new SocketGuildChannel(guild.Discord, model.Id, guild);
} }
} }
internal override void Update(ClientState state, Model model) internal override void Update(ClientState state, Model model)
@@ -49,7 +50,7 @@ namespace Discord.WebSocket
newOverwrites.Add(overwrites[i].ToEntity()); newOverwrites.Add(overwrites[i].ToEntity());
_overwrites = newOverwrites.ToImmutable(); _overwrites = newOverwrites.ToImmutable();
} }
public Task ModifyAsync(Action<GuildChannelProperties> func, RequestOptions options = null) public Task ModifyAsync(Action<GuildChannelProperties> func, RequestOptions options = null)
=> ChannelHelper.ModifyAsync(this, Discord, func, options); => ChannelHelper.ModifyAsync(this, Discord, func, options);
public Task DeleteAsync(RequestOptions options = null) public Task DeleteAsync(RequestOptions options = null)
@@ -115,7 +116,7 @@ namespace Discord.WebSocket
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false);


public new abstract SocketGuildUser GetUser(ulong id);
public new virtual SocketGuildUser GetUser(ulong id) => null;


public override string ToString() => Name; public override string ToString() => Name;
internal new SocketGuildChannel Clone() => MemberwiseClone() as SocketGuildChannel; internal new SocketGuildChannel Clone() => MemberwiseClone() as SocketGuildChannel;
@@ -145,7 +146,7 @@ namespace Discord.WebSocket
=> await RemovePermissionOverwriteAsync(role, options).ConfigureAwait(false); => await RemovePermissionOverwriteAsync(role, options).ConfigureAwait(false);
async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options) async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options)
=> await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false); => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false);
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable();
Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)


Loading…
Cancel
Save