mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-17 14:34:25 +00:00
Fix export JSON detection to use numeric check; rename GuildIds to ServerIds in GetChannelsCommand
Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/ab01ba49-ad07-42ba-b382-27f4d105a92b Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
1835af12d5
commit
f6e710909c
@@ -39,8 +39,8 @@ public partial class ExportChannelsCommand : ExportCommandBase
|
|||||||
if (string.IsNullOrEmpty(trimmed))
|
if (string.IsNullOrEmpty(trimmed))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// JSON array produced by 'list channels' / 'list channels dm'
|
// Snowflake IDs are numeric; non-numeric input is treated as a JSON array
|
||||||
if (trimmed.StartsWith('['))
|
if (!char.IsAsciiDigit(trimmed[0]))
|
||||||
{
|
{
|
||||||
using var doc = JsonDocument.Parse(trimmed);
|
using var doc = JsonDocument.Parse(trimmed);
|
||||||
foreach (var element in doc.RootElement.EnumerateArray())
|
foreach (var element in doc.RootElement.EnumerateArray())
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace DiscordChatExporter.Cli.Commands;
|
|||||||
public partial class GetChannelsCommand : DiscordCommandBase
|
public partial class GetChannelsCommand : DiscordCommandBase
|
||||||
{
|
{
|
||||||
[CommandParameter(0, Name = "server-ids", Description = "Server ID(s).")]
|
[CommandParameter(0, Name = "server-ids", Description = "Server ID(s).")]
|
||||||
public required IReadOnlyList<Snowflake> GuildIds { get; set; }
|
public required IReadOnlyList<Snowflake> ServerIds { get; set; }
|
||||||
|
|
||||||
[CommandOption("include-vc", Description = "Include voice channels.")]
|
[CommandOption("include-vc", Description = "Include voice channels.")]
|
||||||
public bool IncludeVoiceChannels { get; set; } = true;
|
public bool IncludeVoiceChannels { get; set; } = true;
|
||||||
@@ -38,9 +38,9 @@ public partial class GetChannelsCommand : DiscordCommandBase
|
|||||||
|
|
||||||
var allChannels = new List<Channel>();
|
var allChannels = new List<Channel>();
|
||||||
|
|
||||||
foreach (var guildId in GuildIds)
|
foreach (var serverId in ServerIds)
|
||||||
{
|
{
|
||||||
var channels = (await Discord.GetGuildChannelsAsync(guildId, cancellationToken))
|
var channels = (await Discord.GetGuildChannelsAsync(serverId, cancellationToken))
|
||||||
.Where(c => !c.IsCategory)
|
.Where(c => !c.IsCategory)
|
||||||
.Where(c => IncludeVoiceChannels || !c.IsVoice)
|
.Where(c => IncludeVoiceChannels || !c.IsVoice)
|
||||||
.OrderBy(c => c.Parent?.Position)
|
.OrderBy(c => c.Parent?.Position)
|
||||||
@@ -51,7 +51,7 @@ public partial class GetChannelsCommand : DiscordCommandBase
|
|||||||
ThreadInclusionMode != ThreadInclusionMode.None
|
ThreadInclusionMode != ThreadInclusionMode.None
|
||||||
? (
|
? (
|
||||||
await Discord.GetGuildThreadsAsync(
|
await Discord.GetGuildThreadsAsync(
|
||||||
guildId,
|
serverId,
|
||||||
ThreadInclusionMode == ThreadInclusionMode.All,
|
ThreadInclusionMode == ThreadInclusionMode.All,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|||||||
Reference in New Issue
Block a user