2023-07-16 15:55:36 -04:00
|
|
|
|
using System.Threading.Tasks;
|
2019-08-20 11:33:27 -04:00
|
|
|
|
using CliFx.Attributes;
|
2021-03-23 16:38:44 -04:00
|
|
|
|
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;
|
2019-08-20 11:33:27 -04:00
|
|
|
|
|
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
|
2019-08-20 11:33:27 -04:00
|
|
|
|
{
|
2021-12-08 16:50:21 -05:00
|
|
|
|
public override async ValueTask ExecuteAsync(IConsole console)
|
2019-08-20 11:33:27 -04:00
|
|
|
|
{
|
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-10-07 10:06:05 -04:00
|
|
|
|
|
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
|
|
|
|
|
);
|
2021-03-23 16:38:44 -04:00
|
|
|
|
|
2023-08-20 18:03:29 -04:00
|
|
|
|
await ExportAsync(console, channels);
|
2019-08-20 11:33:27 -04:00
|
|
|
|
}
|
2023-08-22 14:17:19 -04:00
|
|
|
|
}
|