diff --git a/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs index d2dc2435..c07fc37b 100644 --- a/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs @@ -57,7 +57,7 @@ public partial class ExportChannelsCommand : ExportCommandBase { throw new CommandException( "No channel IDs provided. " - + "Specify channel IDs as arguments or pipe them from a newline-separated list." + + "Specify channel IDs as arguments or pipe them from the 'list channels' or 'list channels dm' commands." ); } diff --git a/DiscordChatExporter.Cli/Commands/UnwrapChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/UnwrapChannelsCommand.cs index 54db1091..5616f3d5 100644 --- a/DiscordChatExporter.Cli/Commands/UnwrapChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/UnwrapChannelsCommand.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; using System.Threading.Tasks; +using CliFx; using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; @@ -30,11 +31,22 @@ public partial class UnwrapChannelsCommand : DiscordCommandBase await foreach (var line in console.Input.ReadLinesAsync(cancellationToken)) sb.Append(line); - var channels = - JsonSerializer.Deserialize( - sb.ToString().Trim(), - CliJsonSerializerContext.Instance.ChannelArray - ) ?? []; + Channel[] channels; + try + { + channels = + JsonSerializer.Deserialize( + sb.ToString().Trim(), + CliJsonSerializerContext.Instance.ChannelArray + ) ?? []; + } + catch (JsonException) + { + throw new CommandException( + "Failed to parse input as a JSON channel array. " + + "Pipe the output of 'list channels' or 'list channels dm' to this command." + ); + } var result = new List(); var channelsByGuild = new Dictionary>();