Browse Source

Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named.

pull/821/head
pegasy 7 years ago
parent
commit
d59b038efa
12 changed files with 41 additions and 43 deletions
  1. +1
    -1
      src/Discord.Net.Core/Entities/Channels/ICategoryChannel.cs
  2. +1
    -1
      src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs
  3. +2
    -2
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  4. +4
    -4
      src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs
  5. +2
    -2
      src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
  6. +2
    -2
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  7. +8
    -8
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  8. +4
    -6
      src/Discord.Net.Rpc/Entities/Channels/RpcCategoryChannel.cs
  9. +1
    -1
      src/Discord.Net.Rpc/Entities/Channels/RpcGuildChannel.cs
  10. +5
    -5
      src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs
  11. +3
    -3
      src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs
  12. +8
    -8
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

src/Discord.Net.Core/Entities/Channels/IChannelCategory.cs → src/Discord.Net.Core/Entities/Channels/ICategoryChannel.cs View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;

namespace Discord
{
public interface IChannelCategory : IGuildChannel
public interface ICategoryChannel : IGuildChannel
{
}
}

+ 1
- 1
src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs View File

@@ -12,7 +12,7 @@ namespace Discord
/// <summary> Gets the parentid (category) of this channel in the guild's channel list. </summary>
ulong? CategoryId { get; }
/// <summary> Gets the parent channel (category) of this channel. </summary>
Task<IChannelCategory> GetCategory();
Task<ICategoryChannel> GetCategory();
/// <summary> Gets the guild this channel is a member of. </summary>
IGuild Guild { get; }
/// <summary> Gets the id of the guild this channel is a member of. </summary>


+ 2
- 2
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -84,7 +84,7 @@ namespace Discord
Task<IReadOnlyCollection<ITextChannel>> GetTextChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
Task<ITextChannel> GetTextChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
Task<IReadOnlyCollection<IVoiceChannel>> GetVoiceChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
Task<IReadOnlyCollection<IChannelCategory>> GetChannelCategoriesAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
Task<IReadOnlyCollection<ICategoryChannel>> GetCategoryChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
@@ -95,7 +95,7 @@ namespace Discord
/// <summary> Creates a new voice channel. </summary>
Task<IVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null);
/// <summary> Creates a new channel category. </summary>
Task<IChannelCategory> CreateChannelCategoryAsync(string name, RequestOptions options = null);
Task<ICategoryChannel> CreateCategoryChannelAsync(string name, RequestOptions options = null);

Task<IReadOnlyCollection<IGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null);
Task<IGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null);


src/Discord.Net.Rest/Entities/Channels/RestChannelCategory.cs → src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs View File

@@ -9,17 +9,17 @@ using Model = Discord.API.Channel;
namespace Discord.Rest
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestChannelCategory : RestGuildChannel, IChannelCategory
public class RestCategoryChannel : RestGuildChannel, ICategoryChannel
{
public string Mention => MentionUtils.MentionChannel(Id);

internal RestChannelCategory(BaseDiscordClient discord, IGuild guild, ulong id)
internal RestCategoryChannel(BaseDiscordClient discord, IGuild guild, ulong id)
: base(discord, guild, id)
{
}
internal new static RestChannelCategory Create(BaseDiscordClient discord, IGuild guild, Model model)
internal new static RestCategoryChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
{
var entity = new RestChannelCategory(discord, guild, model.Id);
var entity = new RestCategoryChannel(discord, guild, model.Id);
entity.Update(model);
return entity;
}

+ 2
- 2
src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs View File

@@ -17,7 +17,7 @@ namespace Discord.Rest
public string Name { get; private set; }
public int Position { get; private set; }
public ulong? CategoryId { get; private set; }
public async Task<IChannelCategory> GetCategory() => CategoryId == null ? null : await Guild.GetChannelAsync(CategoryId.Value) as IChannelCategory;
public async Task<ICategoryChannel> GetCategory() => CategoryId == null ? null : await Guild.GetChannelAsync(CategoryId.Value) as ICategoryChannel;

public ulong GuildId => Guild.Id;

@@ -35,7 +35,7 @@ namespace Discord.Rest
case ChannelType.Voice:
return RestVoiceChannel.Create(discord, guild, model);
case ChannelType.Category:
return RestChannelCategory.Create(discord, guild, model);
return RestCategoryChannel.Create(discord, guild, model);
default:
// TODO: Channel categories
return new RestGuildChannel(discord, guild, model.Id);


+ 2
- 2
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -157,14 +157,14 @@ namespace Discord.Rest
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestVoiceChannel.Create(client, guild, model);
}
public static async Task<RestChannelCategory> CreateChannelCategoryAsync(IGuild guild, BaseDiscordClient client,
public static async Task<RestCategoryChannel> CreateCategoryChannelAsync(IGuild guild, BaseDiscordClient client,
string name, RequestOptions options)
{
if (name == null) throw new ArgumentNullException(nameof(name));

var args = new CreateGuildChannelParams(name, ChannelType.Category);
var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false);
return RestChannelCategory.Create(client, guild, model);
return RestCategoryChannel.Create(client, guild, model);
}

//Integrations


+ 8
- 8
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -176,10 +176,10 @@ namespace Discord.Rest
var channels = await GuildHelper.GetChannelsAsync(this, Discord, options).ConfigureAwait(false);
return channels.Select(x => x as RestVoiceChannel).Where(x => x != null).ToImmutableArray();
}
public async Task<IReadOnlyCollection<RestChannelCategory>> GetChannelCategoriesAsync(RequestOptions options = null)
public async Task<IReadOnlyCollection<RestCategoryChannel>> GetCategoryChannelsAsync(RequestOptions options = null)
{
var channels = await GuildHelper.GetChannelsAsync(this, Discord, options).ConfigureAwait(false);
return channels.Select(x => x as RestChannelCategory).Where(x => x != null).ToImmutableArray();
return channels.Select(x => x as RestCategoryChannel).Where(x => x != null).ToImmutableArray();
}

public async Task<RestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null)
@@ -222,8 +222,8 @@ namespace Discord.Rest
=> GuildHelper.CreateTextChannelAsync(this, Discord, name, options);
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options);
public Task<RestChannelCategory> CreateChannelCategoryAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateChannelCategoryAsync(this, Discord, name, options);
public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options);

//Integrations
public Task<IReadOnlyCollection<RestGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null)
@@ -311,10 +311,10 @@ namespace Discord.Rest
else
return ImmutableArray.Create<IVoiceChannel>();
}
async Task<IReadOnlyCollection<IChannelCategory>> IGuild.GetChannelCategoriesAsync(CacheMode mode , RequestOptions options)
async Task<IReadOnlyCollection<ICategoryChannel>> IGuild.GetCategoryChannelsAsync(CacheMode mode , RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetChannelCategoriesAsync(options).ConfigureAwait(false);
return await GetCategoryChannelsAsync(options).ConfigureAwait(false);
else
return null;
}
@@ -357,8 +357,8 @@ namespace Discord.Rest
=> await CreateTextChannelAsync(name, options).ConfigureAwait(false);
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
=> await CreateVoiceChannelAsync(name, options).ConfigureAwait(false);
async Task<IChannelCategory> IGuild.CreateChannelCategoryAsync(string name, RequestOptions options)
=> await CreateChannelCategoryAsync(name, options).ConfigureAwait(false);
async Task<ICategoryChannel> IGuild.CreateCategoryChannelAsync(string name, RequestOptions options)
=> await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);

async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options).ConfigureAwait(false);


src/Discord.Net.Rpc/Entities/Channels/RpcChannelCategory.cs → src/Discord.Net.Rpc/Entities/Channels/RpcCategoryChannel.cs View File

@@ -11,21 +11,19 @@ using Model = Discord.API.Rpc.Channel;
namespace Discord.Rpc
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RpcChannelCategory : RpcGuildChannel
public class RpcCategoryChannel : RpcGuildChannel, ICategoryChannel
{
public IReadOnlyCollection<RpcMessage> CachedMessages { get; private set; }

public string Mention => MentionUtils.MentionChannel(Id);
// TODO: Check if RPC includes the 'nsfw' field on Channel models
public bool IsNsfw => ChannelHelper.IsNsfw(this);

internal RpcChannelCategory(DiscordRpcClient discord, ulong id, ulong guildId)
internal RpcCategoryChannel(DiscordRpcClient discord, ulong id, ulong guildId)
: base(discord, id, guildId)
{
}
internal new static RpcChannelCategory Create(DiscordRpcClient discord, Model model)
internal new static RpcCategoryChannel Create(DiscordRpcClient discord, Model model)
{
var entity = new RpcChannelCategory(discord, model.Id, model.GuildId.Value);
var entity = new RpcCategoryChannel(discord, model.Id, model.GuildId.Value);
entity.Update(model);
return entity;
}

+ 1
- 1
src/Discord.Net.Rpc/Entities/Channels/RpcGuildChannel.cs View File

@@ -58,7 +58,7 @@ namespace Discord.Rpc
public override string ToString() => Name;

//IGuildChannel
public Task<IChannelCategory> GetCategory()
public Task<ICategoryChannel> GetCategory()
{
//Always fails
throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object.");


src/Discord.Net.WebSocket/Entities/Channels/SocketChannelCategory.cs → src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs View File

@@ -12,24 +12,24 @@ using Model = Discord.API.Channel;
namespace Discord.WebSocket
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketChannelCategory : SocketGuildChannel, IChannelCategory
public class SocketCategoryChannel : SocketGuildChannel, ICategoryChannel
{
public override IReadOnlyCollection<SocketGuildUser> Users
=> Guild.Users.Where(x => x.VoiceChannel?.Id == Id).ToImmutableArray();

internal SocketChannelCategory(DiscordSocketClient discord, ulong id, SocketGuild guild)
internal SocketCategoryChannel(DiscordSocketClient discord, ulong id, SocketGuild guild)
: base(discord, id, guild)
{
}
internal new static SocketChannelCategory Create(SocketGuild guild, ClientState state, Model model)
internal new static SocketCategoryChannel Create(SocketGuild guild, ClientState state, Model model)
{
var entity = new SocketChannelCategory(guild.Discord, model.Id, guild);
var entity = new SocketCategoryChannel(guild.Discord, model.Id, guild);
entity.Update(state, model);
return entity;
}

private string DebuggerDisplay => $"{Name} ({Id}, Category)";
internal new SocketChannelCategory Clone() => MemberwiseClone() as SocketChannelCategory;
internal new SocketCategoryChannel Clone() => MemberwiseClone() as SocketCategoryChannel;

// IGuildChannel
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)

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

@@ -18,8 +18,8 @@ namespace Discord.WebSocket
public string Name { get; private set; }
public int Position { get; private set; }
public ulong? CategoryId { get; private set; }
public IChannelCategory Category => CategoryId == null ? null : Guild.GetChannel(CategoryId.Value) as IChannelCategory;
Task<IChannelCategory> IGuildChannel.GetCategory() => Task.FromResult(Category);
public ICategoryChannel Category => CategoryId == null ? null : Guild.GetChannel(CategoryId.Value) as ICategoryChannel;
Task<ICategoryChannel> IGuildChannel.GetCategory() => Task.FromResult(Category);

public IReadOnlyCollection<Overwrite> PermissionOverwrites => _overwrites;
public new virtual IReadOnlyCollection<SocketGuildUser> Users => ImmutableArray.Create<SocketGuildUser>();
@@ -38,7 +38,7 @@ namespace Discord.WebSocket
case ChannelType.Voice:
return SocketVoiceChannel.Create(guild, state, model);
case ChannelType.Category:
return SocketChannelCategory.Create(guild, state, model);
return SocketCategoryChannel.Create(guild, state, model);
default:
// TODO: Proper implementation for channel categories
return new SocketGuildChannel(guild.Discord, model.Id, guild);


+ 8
- 8
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -94,8 +94,8 @@ namespace Discord.WebSocket
=> Channels.Select(x => x as SocketTextChannel).Where(x => x != null).ToImmutableArray();
public IReadOnlyCollection<SocketVoiceChannel> VoiceChannels
=> Channels.Select(x => x as SocketVoiceChannel).Where(x => x != null).ToImmutableArray();
public IReadOnlyCollection<SocketChannelCategory> ChannelCategories
=> Channels.Select(x => x as SocketChannelCategory).Where(x => x != null).ToImmutableArray();
public IReadOnlyCollection<SocketCategoryChannel> CategoryChannels
=> Channels.Select(x => x as SocketCategoryChannel).Where(x => x != null).ToImmutableArray();
public SocketGuildUser CurrentUser => _members.TryGetValue(Discord.CurrentUser.Id, out SocketGuildUser member) ? member : null;
public SocketRole EveryoneRole => GetRole(Id);
public IReadOnlyCollection<SocketGuildChannel> Channels
@@ -318,8 +318,8 @@ namespace Discord.WebSocket
=> GuildHelper.CreateTextChannelAsync(this, Discord, name, options);
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options);
public Task<RestChannelCategory> CreateChannelCategoryAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateChannelCategoryAsync(this, Discord, name, options);
public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options);

internal SocketGuildChannel AddChannel(ClientState state, ChannelModel model)
{
@@ -639,8 +639,8 @@ namespace Discord.WebSocket
=> Task.FromResult<ITextChannel>(GetTextChannel(id));
Task<IReadOnlyCollection<IVoiceChannel>> IGuild.GetVoiceChannelsAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IReadOnlyCollection<IVoiceChannel>>(VoiceChannels);
Task<IReadOnlyCollection<IChannelCategory>> IGuild.GetChannelCategoriesAsync(CacheMode mode , RequestOptions options)
=> Task.FromResult<IReadOnlyCollection<IChannelCategory>>(ChannelCategories);
Task<IReadOnlyCollection<ICategoryChannel>> IGuild.GetCategoryChannelsAsync(CacheMode mode , RequestOptions options)
=> Task.FromResult<IReadOnlyCollection<ICategoryChannel>>(CategoryChannels);
Task<IVoiceChannel> IGuild.GetVoiceChannelAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult<IVoiceChannel>(GetVoiceChannel(id));
Task<IVoiceChannel> IGuild.GetAFKChannelAsync(CacheMode mode, RequestOptions options)
@@ -655,8 +655,8 @@ namespace Discord.WebSocket
=> await CreateTextChannelAsync(name, options).ConfigureAwait(false);
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
=> await CreateVoiceChannelAsync(name, options).ConfigureAwait(false);
async Task<IChannelCategory> IGuild.CreateChannelCategoryAsync(string name, RequestOptions options)
=> await CreateChannelCategoryAsync(name, options).ConfigureAwait(false);
async Task<ICategoryChannel> IGuild.CreateCategoryChannelAsync(string name, RequestOptions options)
=> await CreateCategoryChannelAsync(name, options).ConfigureAwait(false);

async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options).ConfigureAwait(false);


Loading…
Cancel
Save