Address code review: fix Snowflake.TryParse usage and remove blank line in channels redirect block

Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/5f305835-64af-456e-b0b4-6163ece1e8cf

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-03 14:45:14 +00:00 committed by GitHub
parent efb371f093
commit 6750195a35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -34,12 +34,25 @@ public partial class ExportChannelsCommand : ExportCommandBase
var channelIds = new List<Snowflake>(ChannelIds); var channelIds = new List<Snowflake>(ChannelIds);
if (channelIds.Count == 0 && console.IsInputRedirected) if (channelIds.Count == 0 && console.IsInputRedirected)
{ {
var lineNumber = 0;
string? line; string? line;
while ((line = await console.Input.ReadLineAsync()) is not null) while ((line = await console.Input.ReadLineAsync()) is not null)
{ {
lineNumber++;
line = line.Trim(); line = line.Trim();
if (!string.IsNullOrEmpty(line)) if (string.IsNullOrEmpty(line))
channelIds.Add(Snowflake.Parse(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);
} }
} }

View file

@ -66,7 +66,6 @@ public partial class GetChannelsCommand : DiscordCommandBase
foreach (var channel in channels) foreach (var channel in channels)
{ {
await console.Output.WriteLineAsync(channel.Id.ToString()); await console.Output.WriteLineAsync(channel.Id.ToString());
foreach (var channelThread in threads.Where(t => t.Parent?.Id == channel.Id)) foreach (var channelThread in threads.Where(t => t.Parent?.Id == channel.Id))
await console.Output.WriteLineAsync(channelThread.Id.ToString()); await console.Output.WriteLineAsync(channelThread.Id.ToString());
} }