Pad outputs from `guilds`, `channels`, `dm` to have more aligned columns

Closes #877
pull/882/head
Oleksii Holub 2 years ago
parent 2463cb5087
commit 7b72f473fd

@ -25,18 +25,18 @@ public class GetChannelsCommand : TokenCommandBase
{
var cancellationToken = console.RegisterCancellationHandler();
var channels = await Discord.GetGuildChannelsAsync(GuildId, cancellationToken);
var textChannels = channels
var channels = (await Discord.GetGuildChannelsAsync(GuildId, cancellationToken))
.Where(c => c.Kind.IsText())
.OrderBy(c => c.Category.Position)
.ThenBy(c => c.Name)
.ToArray();
foreach (var channel in textChannels)
foreach (var channel in channels)
{
// Channel ID
await console.Output.WriteAsync(channel.Id.ToString());
await console.Output.WriteAsync(
channel.Id.ToString().PadRight(18, ' ')
);
// Separator
using (console.WithForegroundColor(ConsoleColor.DarkGray))

@ -16,18 +16,18 @@ public class GetDirectMessageChannelsCommand : TokenCommandBase
{
var cancellationToken = console.RegisterCancellationHandler();
var channels = await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken);
var textChannels = channels
var channels = (await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken))
.Where(c => c.Kind.IsText())
.OrderByDescending(c => c.LastMessageId)
.ThenBy(c => c.Name)
.ToArray();
foreach (var channel in textChannels)
foreach (var channel in channels)
{
// Channel ID
await console.Output.WriteAsync(channel.Id.ToString());
await console.Output.WriteAsync(
channel.Id.ToString().PadRight(18, ' ')
);
// Separator
using (console.WithForegroundColor(ConsoleColor.DarkGray))

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using CliFx.Attributes;
using CliFx.Infrastructure;
using DiscordChatExporter.Cli.Commands.Base;
using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Utils.Extensions;
namespace DiscordChatExporter.Cli.Commands;
@ -15,12 +16,17 @@ public class GetGuildsCommand : TokenCommandBase
{
var cancellationToken = console.RegisterCancellationHandler();
var guilds = await Discord.GetUserGuildsAsync(cancellationToken);
var guilds = (await Discord.GetUserGuildsAsync(cancellationToken))
// Show direct messages first
.OrderByDescending(g => g.Id == Guild.DirectMessages.Id)
.ThenBy(g => g.Name);
foreach (var guild in guilds.OrderBy(g => g.Name))
foreach (var guild in guilds)
{
// Guild ID
await console.Output.WriteAsync(guild.Id.ToString());
await console.Output.WriteAsync(
guild.Id.ToString().PadRight(18, ' ')
);
// Separator
using (console.WithForegroundColor(ConsoleColor.DarkGray))

Loading…
Cancel
Save