mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-04 11:33:08 -06:00
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:
parent
efb371f093
commit
6750195a35
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue