mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-09 04:41:16 -05:00
Fix: catch JsonException in list unwrap; improve export error message
Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/d2a03a38-0ed4-45c7-b8e7-615ffb35c971 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
parent
f8ab926074
commit
1835af12d5
|
|
@ -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."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Channel>();
|
||||
var channelsByGuild = new Dictionary<Snowflake, IReadOnlyList<Channel>>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user