Readded Server.TextChannels and VoiceChannels. Changed Channel.Type to ChannelType.
This commit is contained in:
@@ -59,8 +59,8 @@ namespace Discord
|
||||
public string Topic { get; private set; }
|
||||
/// <summary> Gets the position of this channel relative to other channels in this server. </summary>
|
||||
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>
|
||||
public bool IsPrivate => Recipient != null;
|
||||
@@ -172,7 +172,7 @@ namespace Discord
|
||||
|
||||
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);
|
||||
var newPosChannel = channels.Where(x => x.Position > position).FirstOrDefault();
|
||||
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>
|
||||
public IEnumerable<ulong> BannedUserIds => _bans.Select(x => x.Key);
|
||||
/// <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>
|
||||
public IEnumerable<User> Users => _users.Select(x => x.Value.User);
|
||||
/// <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)));
|
||||
if (user.User == newUser)
|
||||
{
|
||||
foreach (var channel in Channels)
|
||||
foreach (var channel in AllChannels)
|
||||
channel.AddUser(newUser);
|
||||
}
|
||||
return user.User;
|
||||
@@ -396,7 +400,7 @@ namespace Discord
|
||||
Member member;
|
||||
if (_users.TryRemove(id, out member))
|
||||
{
|
||||
foreach (var channel in Channels)
|
||||
foreach (var channel in AllChannels)
|
||||
channel.RemoveUser(id);
|
||||
}
|
||||
return member.User;
|
||||
|
||||
@@ -101,14 +101,14 @@ namespace Discord
|
||||
{
|
||||
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.Voice && x.GetPermissions(this).Connect));
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelPermissions perms = new ChannelPermissions();
|
||||
return Server.Channels
|
||||
return Server.AllChannels
|
||||
.Where(x =>
|
||||
{
|
||||
x.UpdatePermissions(this, perms);
|
||||
|
||||
Reference in New Issue
Block a user