[CLI] Add command to export all channels across all guilds (#373)

pull/379/head
wyattscarpenter 4 years ago committed by GitHub
parent 355b8cb8cf
commit 6d2880ce26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,33 @@
using System.Linq;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using DiscordChatExporter.Cli.Commands.Base;
using DiscordChatExporter.Domain.Discord.Models;
using DiscordChatExporter.Domain.Utilities;
namespace DiscordChatExporter.Cli.Commands
{
[Command("exportall", Description = "Export all direct messages and all channels within all guilds.")]
public class ExportAllCommand : ExportMultipleCommandBase
{
[CommandOption("exclude-dm", 'e', Description = "If this flag is present, direct messages will not be exported.")]
public bool ExcludeDMs { get; set; }
public override async ValueTask ExecuteAsync(IConsole console)
{
if(!ExcludeDMs){
var dmChannels = await GetDiscordClient().GetGuildChannelsAsync(Guild.DirectMessages.Id);
await ExportMultipleAsync(console, dmChannels);
}
var guilds = await GetDiscordClient().GetUserGuildsAsync();
foreach (var guild in guilds.OrderBy(g => g.Name))
{
var guildChannels = await GetDiscordClient().GetGuildChannelsAsync(guild.Id);
await ExportMultipleAsync(console, guildChannels);
}
}
}
}
Loading…
Cancel
Save