Browse Source

Fixed crash on leaving a group channel

tags/1.0-rc
RogueException 8 years ago
parent
commit
f81c2660c7
6 changed files with 9 additions and 5 deletions
  1. +1
    -1
      src/Discord.Net/Entities/WebSocket/CachedDMChannel.cs
  2. +1
    -0
      src/Discord.Net/Entities/WebSocket/CachedGlobalUser.cs
  3. +1
    -2
      src/Discord.Net/Entities/WebSocket/CachedGroupChannel.cs
  4. +3
    -1
      src/Discord.Net/Entities/WebSocket/CachedSelfUser.cs
  5. +1
    -1
      src/Discord.Net/Entities/WebSocket/ICachedPrivateChannel.cs
  6. +2
    -0
      src/Discord.Net/Entities/WebSocket/ICachedUser.cs

+ 1
- 1
src/Discord.Net/Entities/WebSocket/CachedDMChannel.cs View File

@@ -13,7 +13,7 @@ namespace Discord
public new DiscordSocketClient Discord => base.Discord as DiscordSocketClient;
public new CachedDMUser Recipient => base.Recipient as CachedDMUser;
public IReadOnlyCollection<ICachedUser> Members => ImmutableArray.Create<ICachedUser>(Discord.CurrentUser, Recipient);
IReadOnlyCollection<CachedDMUser> ICachedPrivateChannel.Recipients => ImmutableArray.Create(Recipient);
IReadOnlyCollection<ICachedUser> ICachedPrivateChannel.Recipients => ImmutableArray.Create(Recipient);

public CachedDMChannel(DiscordSocketClient discord, CachedDMUser recipient, Model model)
: base(discord, recipient, model)


+ 1
- 0
src/Discord.Net/Entities/WebSocket/CachedGlobalUser.cs View File

@@ -11,6 +11,7 @@ namespace Discord
public Presence Presence { get; private set; }

public new DiscordSocketClient Discord { get { throw new NotSupportedException(); } }
CachedGlobalUser ICachedUser.User => this;

public CachedGlobalUser(Model model)
: base(model)


+ 1
- 2
src/Discord.Net/Entities/WebSocket/CachedGroupChannel.cs View File

@@ -8,7 +8,6 @@ using MessageModel = Discord.API.Message;
using Model = Discord.API.Channel;
using UserModel = Discord.API.User;
using VoiceStateModel = Discord.API.VoiceState;
using Discord.API;

namespace Discord
{
@@ -20,7 +19,7 @@ namespace Discord
public new DiscordSocketClient Discord => base.Discord as DiscordSocketClient;
public IReadOnlyCollection<ICachedUser> Members
=> _users.Select(x => x.Value as ICachedUser).Concat(ImmutableArray.Create(Discord.CurrentUser)).ToReadOnlyCollection(() => _users.Count + 1);
public new IReadOnlyCollection<CachedDMUser> Recipients => _users.Cast<CachedDMUser>().ToReadOnlyCollection(_users);
public new IReadOnlyCollection<ICachedUser> Recipients => _users.Select(x => x.Value as ICachedUser).ToReadOnlyCollection(_users);

public CachedGroupChannel(DiscordSocketClient discord, Model model)
: base(discord, model)


+ 3
- 1
src/Discord.Net/Entities/WebSocket/CachedSelfUser.cs View File

@@ -1,10 +1,12 @@
using Model = Discord.API.User;
using System;
using Model = Discord.API.User;

namespace Discord
{
internal class CachedSelfUser : SelfUser, ICachedUser
{
public new DiscordSocketClient Discord => base.Discord as DiscordSocketClient;
CachedGlobalUser ICachedUser.User { get { throw new NotSupportedException(); } }

public CachedSelfUser(DiscordSocketClient discord, Model model)
: base(discord, model)


+ 1
- 1
src/Discord.Net/Entities/WebSocket/ICachedPrivateChannel.cs View File

@@ -4,6 +4,6 @@ namespace Discord
{
internal interface ICachedPrivateChannel : ICachedChannel, IPrivateChannel
{
new IReadOnlyCollection<CachedDMUser> Recipients { get; }
new IReadOnlyCollection<ICachedUser> Recipients { get; }
}
}

+ 2
- 0
src/Discord.Net/Entities/WebSocket/ICachedUser.cs View File

@@ -2,6 +2,8 @@
{
internal interface ICachedUser : IUser, ICachedEntity<ulong>
{
CachedGlobalUser User { get; }

ICachedUser Clone();
}
}

Loading…
Cancel
Save