mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-27 21:24:12 -04:00
[CLI] Add command to export all channels across all guilds (#373)
This commit is contained in:
parent
355b8cb8cf
commit
6d2880ce26
1 changed files with 33 additions and 0 deletions
33
DiscordChatExporter.Cli/Commands/ExportAllCommand.cs
Normal file
33
DiscordChatExporter.Cli/Commands/ExportAllCommand.cs
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue