diff --git a/DiscordChatExporter.Domain/Discord/DiscordClient.cs b/DiscordChatExporter.Domain/Discord/DiscordClient.cs index 1cd1e084..ba19e2a2 100644 --- a/DiscordChatExporter.Domain/Discord/DiscordClient.cs +++ b/DiscordChatExporter.Domain/Discord/DiscordClient.cs @@ -171,9 +171,20 @@ namespace DiscordChatExporter.Domain.Discord public async ValueTask GetChannelCategoryAsync(Snowflake channelId) { - var response = await GetJsonResponseAsync($"channels/{channelId}"); + try + { + var response = await GetJsonResponseAsync($"channels/{channelId}"); + return ChannelCategory.Parse(response); + } + /*** + * In some cases, the Discord API returns an empty body when requesting some channel category info. + * Instead, we use an empty channel category as a fallback. + */ + catch (DiscordChatExporterException) + { + return ChannelCategory.Empty; + } - return ChannelCategory.Parse(response); } public async ValueTask GetChannelAsync(Snowflake channelId) diff --git a/DiscordChatExporter.Domain/Discord/Models/ChannelCategory.cs b/DiscordChatExporter.Domain/Discord/Models/ChannelCategory.cs index e8d5471f..8fcdce26 100644 --- a/DiscordChatExporter.Domain/Discord/Models/ChannelCategory.cs +++ b/DiscordChatExporter.Domain/Discord/Models/ChannelCategory.cs @@ -44,5 +44,7 @@ namespace DiscordChatExporter.Domain.Discord.Models position.Value ); } + + public static ChannelCategory Empty { get; } = new(Snowflake.Zero, "Missing", 0); } -} \ No newline at end of file +}