File tree Expand file tree Collapse file tree
DiscordChatExporter.Cli/Commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public override async ValueTask ExecuteAsync(IConsole console)
5757 {
5858 throw new CommandException (
5959 "No channel IDs provided. "
60- + "Specify channel IDs as arguments or pipe them from a newline-separated list."
60+ + "Specify channel IDs as arguments or pipe them from the 'list channels' or ' list channels dm' commands ."
6161 ) ;
6262 }
6363
Original file line number Diff line number Diff line change 22using System . Text ;
33using System . Text . Json ;
44using System . Threading . Tasks ;
5+ using CliFx ;
56using CliFx . Binding ;
67using CliFx . Infrastructure ;
78using DiscordChatExporter . Cli . Commands . Base ;
@@ -30,11 +31,22 @@ public override async ValueTask ExecuteAsync(IConsole console)
3031 await foreach ( var line in console . Input . ReadLinesAsync ( cancellationToken ) )
3132 sb . Append ( line ) ;
3233
33- var channels =
34- JsonSerializer . Deserialize (
35- sb . ToString ( ) . Trim ( ) ,
36- CliJsonSerializerContext . Instance . ChannelArray
37- ) ?? [ ] ;
34+ Channel [ ] channels ;
35+ try
36+ {
37+ channels =
38+ JsonSerializer . Deserialize (
39+ sb . ToString ( ) . Trim ( ) ,
40+ CliJsonSerializerContext . Instance . ChannelArray
41+ ) ?? [ ] ;
42+ }
43+ catch ( JsonException )
44+ {
45+ throw new CommandException (
46+ "Failed to parse input as a JSON channel array. "
47+ + "Pipe the output of 'list channels' or 'list channels dm' to this command."
48+ ) ;
49+ }
3850
3951 var result = new List < Channel > ( ) ;
4052 var channelsByGuild = new Dictionary < Snowflake , IReadOnlyList < Channel > > ( ) ;
You can’t perform that action at this time.
0 commit comments