Add support for channel categories (#907)
commit a85c5814a74e473e95fe172f0379cbc7f9f951d8
Author: Christopher F <computerizedtaco@gmail.com>
Date: Sat Jan 6 22:25:48 2018 -0500
Code cleanup
commit 4b243fd3dd99152b4ebc7ee01d704bd8e57eeee1
Author: Christopher F <computerizedtaco@gmail.com>
Date: Sat Jan 6 22:08:28 2018 -0500
Add support for channel categories (#907)
commit 41ed9106f2b05530acbf06b245c9aa618011d815
Author: mrspits4ever <spits.lucas@gmail.com>
Date: Thu Dec 14 20:02:57 2017 +0100
removed mentioning support for RestCategoryChannel, added channels property to SocketCategoryChannel
commit 71142c310847886dff80c49e9357dd0786d67a1b
Merge: 4589d731 678a7238
Author: mrspits4ever <spits.lucas@gmail.com>
Date: Wed Dec 13 21:17:53 2017 +0100
Merge branch 'dev' of https://github.com/RogueException/Discord.Net into feature/channel-categories
commit 4589d73187871c98485ed25c6d223706927af7ec
Author: mrspits4ever <spits.lucas@gmail.com>
Date: Wed Dec 13 21:17:46 2017 +0100
adressed requested changes
commit d59b038efa048b2279602e2015ddd2c185e58d63
Author: pegasy <pegasy@users.noreply.github.com>
Date: Mon Sep 25 18:53:23 2017 +0200
Renamed classes / properties / methods to use CategoryChannel instead of ChannelCategory to be consistant with how text / voice channels are named.
commit 5c4777dc8cc443108f2e7e4afae98824c9a32b1f
Author: pegasy <pegasy@users.noreply.github.com>
Date: Sun Sep 24 19:08:25 2017 +0200
removed Guild from class name for ChannelCategory
Renamed all properties to use Category instead of Parent
Throw exception on GetUsers / GetInvites etc for categories
commit e18bd8c799d2327270021c05866cb2e97ad4671b
Author: pegasy <pegasy@users.noreply.github.com>
Date: Sun Sep 24 15:49:51 2017 +0200
Add support for channel categories (as its own channel type)
This commit is contained in:
@@ -14,13 +14,13 @@ namespace Discord.Rest
|
||||
internal static class ChannelHelper
|
||||
{
|
||||
//General
|
||||
public static async Task DeleteAsync(IChannel channel, BaseDiscordClient client,
|
||||
public static async Task DeleteAsync(IChannel channel, BaseDiscordClient client,
|
||||
RequestOptions options)
|
||||
{
|
||||
{
|
||||
await client.ApiClient.DeleteChannelAsync(channel.Id, options).ConfigureAwait(false);
|
||||
}
|
||||
public static async Task<Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client,
|
||||
Action<GuildChannelProperties> func,
|
||||
public static async Task<Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client,
|
||||
Action<GuildChannelProperties> func,
|
||||
RequestOptions options)
|
||||
{
|
||||
var args = new GuildChannelProperties();
|
||||
@@ -28,12 +28,13 @@ namespace Discord.Rest
|
||||
var apiArgs = new API.Rest.ModifyGuildChannelParams
|
||||
{
|
||||
Name = args.Name,
|
||||
Position = args.Position
|
||||
Position = args.Position,
|
||||
CategoryId = args.CategoryId
|
||||
};
|
||||
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
|
||||
}
|
||||
public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,
|
||||
Action<TextChannelProperties> func,
|
||||
public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,
|
||||
Action<TextChannelProperties> func,
|
||||
RequestOptions options)
|
||||
{
|
||||
var args = new TextChannelProperties();
|
||||
@@ -42,13 +43,14 @@ namespace Discord.Rest
|
||||
{
|
||||
Name = args.Name,
|
||||
Position = args.Position,
|
||||
CategoryId = args.CategoryId,
|
||||
Topic = args.Topic,
|
||||
IsNsfw = args.IsNsfw
|
||||
};
|
||||
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
|
||||
}
|
||||
public static async Task<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client,
|
||||
Action<VoiceChannelProperties> func,
|
||||
public static async Task<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client,
|
||||
Action<VoiceChannelProperties> func,
|
||||
RequestOptions options)
|
||||
{
|
||||
var args = new VoiceChannelProperties();
|
||||
@@ -58,6 +60,7 @@ namespace Discord.Rest
|
||||
Bitrate = args.Bitrate,
|
||||
Name = args.Name,
|
||||
Position = args.Position,
|
||||
CategoryId = args.CategoryId,
|
||||
UserLimit = args.UserLimit.IsSpecified ? (args.UserLimit.Value ?? 0) : Optional.Create<int>()
|
||||
};
|
||||
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
|
||||
@@ -87,7 +90,7 @@ namespace Discord.Rest
|
||||
}
|
||||
|
||||
//Messages
|
||||
public static async Task<RestMessage> GetMessageAsync(IMessageChannel channel, BaseDiscordClient client,
|
||||
public static async Task<RestMessage> GetMessageAsync(IMessageChannel channel, BaseDiscordClient client,
|
||||
ulong id, RequestOptions options)
|
||||
{
|
||||
var guildId = (channel as IGuildChannel)?.GuildId;
|
||||
@@ -98,7 +101,7 @@ namespace Discord.Rest
|
||||
var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable());
|
||||
return RestMessage.Create(client, channel, author, model);
|
||||
}
|
||||
public static IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessageChannel channel, BaseDiscordClient client,
|
||||
public static IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessageChannel channel, BaseDiscordClient client,
|
||||
ulong? fromMessageId, Direction dir, int limit, RequestOptions options)
|
||||
{
|
||||
if (dir == Direction.Around)
|
||||
@@ -124,7 +127,7 @@ namespace Discord.Rest
|
||||
foreach (var model in models)
|
||||
{
|
||||
var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable());
|
||||
builder.Add(RestMessage.Create(client, channel, author, model));
|
||||
builder.Add(RestMessage.Create(client, channel, author, model));
|
||||
}
|
||||
return builder.ToImmutable();
|
||||
},
|
||||
@@ -180,7 +183,7 @@ namespace Discord.Rest
|
||||
var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS };
|
||||
var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false);
|
||||
return RestUserMessage.Create(client, channel, client.CurrentUser, model);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task DeleteMessagesAsync(ITextChannel channel, BaseDiscordClient client,
|
||||
IEnumerable<ulong> messageIds, RequestOptions options)
|
||||
@@ -277,7 +280,7 @@ namespace Discord.Rest
|
||||
{
|
||||
await client.ApiClient.TriggerTypingIndicatorAsync(channel.Id, options).ConfigureAwait(false);
|
||||
}
|
||||
public static IDisposable EnterTypingState(IMessageChannel channel, BaseDiscordClient client,
|
||||
public static IDisposable EnterTypingState(IMessageChannel channel, BaseDiscordClient client,
|
||||
RequestOptions options)
|
||||
=> new TypingNotifier(client, channel, options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user