@@ -59,8 +59,8 @@ namespace Discord | |||||
public string Topic { get; private set; } | public string Topic { get; private set; } | ||||
/// <summary> Gets the position of this channel relative to other channels in this server. </summary> | /// <summary> Gets the position of this channel relative to other channels in this server. </summary> | ||||
public int Position { get; private set; } | public int Position { get; private set; } | ||||
/// <summary> Gets the type of this channel (see ChannelTypes). </summary> | |||||
public string Type { get; private set; } | |||||
/// <summary> Gets the type of this channel). </summary> | |||||
public ChannelType Type { get; private set; } | |||||
/// <summary> Gets true if this is a private chat with another user. </summary> | /// <summary> Gets true if this is a private chat with another user. </summary> | ||||
public bool IsPrivate => Recipient != null; | public bool IsPrivate => Recipient != null; | ||||
@@ -172,7 +172,7 @@ namespace Discord | |||||
if (position != null) | if (position != null) | ||||
{ | { | ||||
Channel[] channels = Server.Channels.Where(x => x.Type == Type).OrderBy(x => x.Position).ToArray(); | |||||
Channel[] channels = Server.AllChannels.Where(x => x.Type == Type).OrderBy(x => x.Position).ToArray(); | |||||
int oldPos = Array.IndexOf(channels, this); | int oldPos = Array.IndexOf(channels, this); | ||||
var newPosChannel = channels.Where(x => x.Position > position).FirstOrDefault(); | var newPosChannel = channels.Where(x => x.Position > position).FirstOrDefault(); | ||||
int newPos = (newPosChannel != null ? Array.IndexOf(channels, newPosChannel) : channels.Length) - 1; | int newPos = (newPosChannel != null ? Array.IndexOf(channels, newPosChannel) : channels.Length) - 1; | ||||
@@ -68,7 +68,11 @@ namespace Discord | |||||
/// <summary> Gets a collection of the ids of all users banned on this server. </summary> | /// <summary> Gets a collection of the ids of all users banned on this server. </summary> | ||||
public IEnumerable<ulong> BannedUserIds => _bans.Select(x => x.Key); | public IEnumerable<ulong> BannedUserIds => _bans.Select(x => x.Key); | ||||
/// <summary> Gets a collection of all channels in this server. </summary> | /// <summary> Gets a collection of all channels in this server. </summary> | ||||
public IEnumerable<Channel> Channels => _channels.Select(x => x.Value); | |||||
public IEnumerable<Channel> AllChannels => _channels.Select(x => x.Value); | |||||
/// <summary> Gets a collection of text channels in this server. </summary> | |||||
public IEnumerable<Channel> TextChannels => _channels.Select(x => x.Value).Where(x => x.Type == ChannelType.Text); | |||||
/// <summary> Gets a collection of voice channels in this server. </summary> | |||||
public IEnumerable<Channel> VoiceChannels => _channels.Select(x => x.Value).Where(x => x.Type == ChannelType.Voice); | |||||
/// <summary> Gets a collection of all members in this server. </summary> | /// <summary> Gets a collection of all members in this server. </summary> | ||||
public IEnumerable<User> Users => _users.Select(x => x.Value.User); | public IEnumerable<User> Users => _users.Select(x => x.Value.User); | ||||
/// <summary> Gets a collection of all roles in this server. </summary> | /// <summary> Gets a collection of all roles in this server. </summary> | ||||
@@ -386,7 +390,7 @@ namespace Discord | |||||
var user = _users.GetOrAdd(id, x => new Member(new User(Client, id, this))); | var user = _users.GetOrAdd(id, x => new Member(new User(Client, id, this))); | ||||
if (user.User == newUser) | if (user.User == newUser) | ||||
{ | { | ||||
foreach (var channel in Channels) | |||||
foreach (var channel in AllChannels) | |||||
channel.AddUser(newUser); | channel.AddUser(newUser); | ||||
} | } | ||||
return user.User; | return user.User; | ||||
@@ -396,7 +400,7 @@ namespace Discord | |||||
Member member; | Member member; | ||||
if (_users.TryRemove(id, out member)) | if (_users.TryRemove(id, out member)) | ||||
{ | { | ||||
foreach (var channel in Channels) | |||||
foreach (var channel in AllChannels) | |||||
channel.RemoveUser(id); | channel.RemoveUser(id); | ||||
} | } | ||||
return member.User; | return member.User; | ||||
@@ -101,14 +101,14 @@ namespace Discord | |||||
{ | { | ||||
if (Client.Config.UsePermissionsCache) | if (Client.Config.UsePermissionsCache) | ||||
{ | { | ||||
return Server.Channels.Where(x => | |||||
return Server.AllChannels.Where(x => | |||||
(x.Type == ChannelType.Text && x.GetPermissions(this).ReadMessages) || | (x.Type == ChannelType.Text && x.GetPermissions(this).ReadMessages) || | ||||
(x.Type == ChannelType.Voice && x.GetPermissions(this).Connect)); | (x.Type == ChannelType.Voice && x.GetPermissions(this).Connect)); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
ChannelPermissions perms = new ChannelPermissions(); | ChannelPermissions perms = new ChannelPermissions(); | ||||
return Server.Channels | |||||
return Server.AllChannels | |||||
.Where(x => | .Where(x => | ||||
{ | { | ||||
x.UpdatePermissions(this, perms); | x.UpdatePermissions(this, perms); | ||||