mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-06 21:09:12 -05:00
Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/58698f45-e22e-4bd4-aec4-31f801051467 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System.Linq;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using CliFx.Binding;
|
|
using CliFx.Infrastructure;
|
|
using DiscordChatExporter.Cli.Commands.Base;
|
|
using DiscordChatExporter.Cli.Utils.Json;
|
|
using DiscordChatExporter.Core.Discord.Data;
|
|
using DiscordChatExporter.Core.Utils.Extensions;
|
|
|
|
namespace DiscordChatExporter.Cli.Commands;
|
|
|
|
[Command("list channels dm", Description = "Gets the list of direct message channels.")]
|
|
public partial class GetDirectChannelsCommand : DiscordCommandBase
|
|
{
|
|
public override async ValueTask ExecuteAsync(IConsole console)
|
|
{
|
|
await base.ExecuteAsync(console);
|
|
|
|
var cancellationToken = console.RegisterCancellationHandler();
|
|
|
|
var channels = (
|
|
await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken)
|
|
)
|
|
.OrderByDescending(c => c.LastMessageId)
|
|
.ThenBy(c => c.Name)
|
|
.ToArray();
|
|
|
|
await console.Output.WriteLineAsync(
|
|
JsonSerializer.Serialize(channels, CliJsonSerializerContext.Instance.ChannelArray)
|
|
);
|
|
}
|
|
}
|