Fixed User.Channels
This commit is contained in:
@@ -82,7 +82,32 @@ namespace Discord
|
|||||||
|
|
||||||
/// <summary> Returns a collection of all channels this user is a member of. </summary>
|
/// <summary> Returns a collection of all channels this user is a member of. </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public IEnumerable<Channel> Channels => _channels.Select(x => x.Value);
|
public IEnumerable<Channel> Channels
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_server.Id != null)
|
||||||
|
{
|
||||||
|
return _permissions
|
||||||
|
.Where(x => x.Value.ReadMessages)
|
||||||
|
.Select(x =>
|
||||||
|
{
|
||||||
|
Channel channel = null;
|
||||||
|
_channels.TryGetValue(x.Key, out channel);
|
||||||
|
return channel;
|
||||||
|
})
|
||||||
|
.Where(x => x != null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var privateChannel = PrivateChannel;
|
||||||
|
if (privateChannel != null)
|
||||||
|
return new Channel[] { privateChannel };
|
||||||
|
else
|
||||||
|
return new Channel[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal User(DiscordClient client, string id, string serverId)
|
internal User(DiscordClient client, string id, string serverId)
|
||||||
: base(client, id)
|
: base(client, id)
|
||||||
@@ -309,17 +334,23 @@ namespace Discord
|
|||||||
|
|
||||||
internal void AddChannel(Channel channel)
|
internal void AddChannel(Channel channel)
|
||||||
{
|
{
|
||||||
var perms = new ChannelPermissions();
|
if (_server.Id != null)
|
||||||
perms.Lock();
|
{
|
||||||
_channels.TryAdd(channel.Id, channel);
|
var perms = new ChannelPermissions();
|
||||||
_permissions.TryAdd(channel.Id, perms);
|
perms.Lock();
|
||||||
UpdateChannelPermissions(channel);
|
_channels.TryAdd(channel.Id, channel);
|
||||||
|
_permissions.TryAdd(channel.Id, perms);
|
||||||
|
UpdateChannelPermissions(channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
internal void RemoveChannel(Channel channel)
|
internal void RemoveChannel(Channel channel)
|
||||||
{
|
{
|
||||||
ChannelPermissions ignored;
|
if (_server.Id != null)
|
||||||
_channels.TryRemove(channel.Id, out channel);
|
{
|
||||||
_permissions.TryRemove(channel.Id, out ignored);
|
ChannelPermissions ignored;
|
||||||
|
_channels.TryRemove(channel.Id, out channel);
|
||||||
|
_permissions.TryRemove(channel.Id, out ignored);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasRole(Role role)
|
public bool HasRole(Role role)
|
||||||
|
|||||||
Reference in New Issue
Block a user