You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using CliFx.Attributes;
|
|
using CliFx.Infrastructure;
|
|
using DiscordChatExporter.Cli.Commands.Base;
|
|
using DiscordChatExporter.Core.Discord;
|
|
using DiscordChatExporter.Core.Discord.Data;
|
|
using DiscordChatExporter.Core.Utils.Extensions;
|
|
|
|
namespace DiscordChatExporter.Cli.Commands;
|
|
|
|
[Command("exportguild", Description = "Export all channels within specified guild.")]
|
|
public class ExportGuildCommand : ExportCommandBase
|
|
{
|
|
[CommandOption(
|
|
"guild",
|
|
'g',
|
|
Description = "Guild ID."
|
|
)]
|
|
public required Snowflake GuildId { get; init; }
|
|
|
|
public override async ValueTask ExecuteAsync(IConsole console)
|
|
{
|
|
await base.ExecuteAsync(console);
|
|
|
|
var cancellationToken = console.RegisterCancellationHandler();
|
|
|
|
await console.Output.WriteLineAsync("Fetching channels...");
|
|
|
|
var channels = (await Discord.GetGuildChannelsAsync(GuildId, cancellationToken))
|
|
.Where(c => c.Kind != ChannelKind.GuildCategory)
|
|
.ToArray();
|
|
|
|
await base.ExecuteAsync(console, channels);
|
|
}
|
|
} |