diff --git a/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs index 86d59bb8..1fbb085e 100644 --- a/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs @@ -34,12 +34,25 @@ public partial class ExportChannelsCommand : ExportCommandBase var channelIds = new List(ChannelIds); if (channelIds.Count == 0 && console.IsInputRedirected) { + var lineNumber = 0; string? line; while ((line = await console.Input.ReadLineAsync()) is not null) { + lineNumber++; line = line.Trim(); - if (!string.IsNullOrEmpty(line)) - channelIds.Add(Snowflake.Parse(line)); + if (string.IsNullOrEmpty(line)) + continue; + + var snowflake = Snowflake.TryParse(line); + if (snowflake is null) + { + throw new CommandException( + $"Invalid channel ID on line {lineNumber}: '{line}'. " + + "Each line must contain a valid channel ID." + ); + } + + channelIds.Add(snowflake.Value); } } diff --git a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs index b603d9cd..59b43df9 100644 --- a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs @@ -66,7 +66,6 @@ public partial class GetChannelsCommand : DiscordCommandBase foreach (var channel in channels) { await console.Output.WriteLineAsync(channel.Id.ToString()); - foreach (var channelThread in threads.Where(t => t.Parent?.Id == channel.Id)) await console.Output.WriteLineAsync(channelThread.Id.ToString()); }