DiscordChatExporter/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs

28 lines
859 B
C#
Raw Normal View History

2023-07-16 15:55:36 -04:00
using System.Threading.Tasks;
using CliFx.Attributes;
using CliFx.Infrastructure;
2020-04-21 14:30:42 -04:00
using DiscordChatExporter.Cli.Commands.Base;
2021-02-21 20:15:09 -05:00
using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Utils.Extensions;
2021-12-08 16:50:21 -05:00
namespace DiscordChatExporter.Cli.Commands;
2023-05-20 00:09:19 -04:00
[Command("exportdm", Description = "Exports all direct message channels.")]
2021-12-08 16:50:21 -05:00
public class ExportDirectMessagesCommand : ExportCommandBase
{
2021-12-08 16:50:21 -05:00
public override async ValueTask ExecuteAsync(IConsole console)
{
2022-03-06 12:24:22 -05:00
await base.ExecuteAsync(console);
2021-12-08 16:50:21 -05:00
var cancellationToken = console.RegisterCancellationHandler();
2021-12-08 16:50:21 -05:00
await console.Output.WriteLineAsync("Fetching channels...");
2023-08-22 14:17:19 -04:00
var channels = await Discord.GetGuildChannelsAsync(
Guild.DirectMessages.Id,
cancellationToken
);
await ExportAsync(console, channels);
}
2023-08-22 14:17:19 -04:00
}