diff --git a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs index 1019f86..bbd6961 100644 --- a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs @@ -184,7 +184,7 @@ public abstract class ExportCommandBase : DiscordCommandBase try { await progressContext.StartTaskAsync( - $"{channel.Category} / {channel.Name}", + $"{channel.ParentNameWithFallback} / {channel.Name}", async progress => { var guild = await Discord.GetGuildAsync( @@ -246,7 +246,7 @@ public abstract class ExportCommandBase : DiscordCommandBase foreach (var (channel, error) in errorsByChannel) { - await console.Error.WriteAsync($"{channel.Category} / {channel.Name}: "); + await console.Error.WriteAsync($"{channel.ParentNameWithFallback} / {channel.Name}: "); using (console.WithForegroundColor(ConsoleColor.Red)) await console.Error.WriteLineAsync(error); diff --git a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs index 8fa47f3..917efdb 100644 --- a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs @@ -77,7 +77,7 @@ public class GetChannelsCommand : DiscordCommandBase // Channel category / name using (console.WithForegroundColor(ConsoleColor.White)) - await console.Output.WriteLineAsync($"{channel.Category} / {channel.Name}"); + await console.Output.WriteLineAsync($"{channel.ParentNameWithFallback} / {channel.Name}"); var channelThreads = threads.Where(t => t.Parent?.Id == channel.Id).ToArray(); var channelThreadIdMaxLength = channelThreads diff --git a/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs index 74123de..8a118b7 100644 --- a/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs @@ -44,7 +44,7 @@ public class GetDirectChannelsCommand : DiscordCommandBase // Channel category / name using (console.WithForegroundColor(ConsoleColor.White)) - await console.Output.WriteLineAsync($"{channel.Category} / {channel.Name}"); + await console.Output.WriteLineAsync($"{channel.ParentNameWithFallback} / {channel.Name}"); } } } diff --git a/DiscordChatExporter.Core/Discord/Data/Channel.cs b/DiscordChatExporter.Core/Discord/Data/Channel.cs index 981841d..431f675 100644 --- a/DiscordChatExporter.Core/Discord/Data/Channel.cs +++ b/DiscordChatExporter.Core/Discord/Data/Channel.cs @@ -24,7 +24,7 @@ public partial record Channel( // channels without a parent (i.e. mostly DM channels) or channels // with an inaccessible parent (i.e. inside private categories) had // a fallback category created for them. - public string Category => + public string ParentNameWithFallback => Parent?.Name ?? Kind switch { @@ -41,6 +41,9 @@ public partial record Channel( // Only needed for WPF data binding. Don't use anywhere else. public bool IsVoice => Kind.IsVoice(); + + // Only needed for WPF data binding. Don't use anywhere else. + public bool IsThread => Kind.IsThread(); } public partial record Channel diff --git a/DiscordChatExporter.Core/Exporting/ExportRequest.cs b/DiscordChatExporter.Core/Exporting/ExportRequest.cs index deb122a..26c5a54 100644 --- a/DiscordChatExporter.Core/Exporting/ExportRequest.cs +++ b/DiscordChatExporter.Core/Exporting/ExportRequest.cs @@ -92,7 +92,9 @@ public partial class ExportRequest var buffer = new StringBuilder(); // Guild and channel names - buffer.Append($"{guild.Name} - {channel.Category} - {channel.Name} [{channel.Id}]"); + buffer.Append( + $"{guild.Name} - {channel.ParentNameWithFallback} - {channel.Name} [{channel.Id}]" + ); // Date range if (after is not null || before is not null) diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index 435997f..b230336 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -273,7 +273,7 @@ internal class JsonMessageWriter : MessageWriter _writer.WriteString("id", Context.Request.Channel.Id.ToString()); _writer.WriteString("type", Context.Request.Channel.Kind.ToString()); _writer.WriteString("categoryId", Context.Request.Channel.Parent?.Id.ToString()); - _writer.WriteString("category", Context.Request.Channel.Category); + _writer.WriteString("category", Context.Request.Channel.ParentNameWithFallback); _writer.WriteString("name", Context.Request.Channel.Name); _writer.WriteString("topic", Context.Request.Channel.Topic); diff --git a/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs b/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs index 04ea408..77f7d32 100644 --- a/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs @@ -201,7 +201,7 @@ internal class PlainTextMessageWriter : MessageWriter await _writer.WriteLineAsync(new string('=', 62)); await _writer.WriteLineAsync($"Guild: {Context.Request.Guild.Name}"); await _writer.WriteLineAsync( - $"Channel: {Context.Request.Channel.Category} / {Context.Request.Channel.Name}" + $"Channel: {Context.Request.Channel.ParentNameWithFallback} / {Context.Request.Channel.Name}" ); if (!string.IsNullOrWhiteSpace(Context.Request.Channel.Topic)) diff --git a/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml b/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml index b7b2353..b1742f7 100644 --- a/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml @@ -1004,7 +1004,7 @@