Refactor IsTextChannel and IsVoiceChannel to extensions

This commit is contained in:
Oleksii Holub
2022-06-28 16:38:44 +03:00
parent 5755334492
commit 2c7986c4e6
10 changed files with 26 additions and 19 deletions

View File

@@ -33,7 +33,7 @@ public class ExportAllCommand : ExportCommandBase
await foreach (var channel in Discord.GetGuildChannelsAsync(guild.Id, cancellationToken))
{
// Skip non-text channels
if (!channel.IsTextChannel)
if (!channel.Kind.IsText())
continue;
channels.Add(channel);

View File

@@ -19,7 +19,7 @@ public class ExportDirectMessagesCommand : ExportCommandBase
await console.Output.WriteLineAsync("Fetching channels...");
var channels = await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken);
var textChannels = channels.Where(c => c.IsTextChannel).ToArray();
var textChannels = channels.Where(c => c.Kind.IsText()).ToArray();
await base.ExecuteAsync(console, textChannels);
}

View File

@@ -4,6 +4,7 @@ using CliFx.Attributes;
using CliFx.Infrastructure;
using DiscordChatExporter.Cli.Commands.Base;
using DiscordChatExporter.Core.Discord;
using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Utils.Extensions;
namespace DiscordChatExporter.Cli.Commands;
@@ -27,7 +28,7 @@ public class ExportGuildCommand : ExportCommandBase
await console.Output.WriteLineAsync("Fetching channels...");
var channels = await Discord.GetGuildChannelsAsync(GuildId, cancellationToken);
var textChannels = channels.Where(c => c.IsTextChannel).ToArray();
var textChannels = channels.Where(c => c.Kind.IsText()).ToArray();
await base.ExecuteAsync(console, textChannels);
}

View File

@@ -5,6 +5,7 @@ using CliFx.Attributes;
using CliFx.Infrastructure;
using DiscordChatExporter.Cli.Commands.Base;
using DiscordChatExporter.Core.Discord;
using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Utils.Extensions;
namespace DiscordChatExporter.Cli.Commands;
@@ -27,7 +28,7 @@ public class GetChannelsCommand : TokenCommandBase
var channels = await Discord.GetGuildChannelsAsync(GuildId, cancellationToken);
var textChannels = channels
.Where(c => c.IsTextChannel)
.Where(c => c.Kind.IsText())
.OrderBy(c => c.Category.Position)
.ThenBy(c => c.Name)
.ToArray();

View File

@@ -19,7 +19,7 @@ public class GetDirectMessageChannelsCommand : TokenCommandBase
var channels = await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken);
var textChannels = channels
.Where(c => c.IsTextChannel)
.Where(c => c.Kind.IsText())
.OrderBy(c => c.Category.Position)
.ThenBy(c => c.Name)
.ToArray();