mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-01 15:49:11 +00:00
[CLI] Fix missing channel category bug when API returns empty string (#492)
This commit is contained in:
committed by
GitHub
parent
8b9afe45b9
commit
e49cf997ea
@@ -171,9 +171,20 @@ namespace DiscordChatExporter.Domain.Discord
|
||||
|
||||
public async ValueTask<ChannelCategory> 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<Channel> GetChannelAsync(Snowflake channelId)
|
||||
|
||||
@@ -44,5 +44,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
|
||||
position.Value
|
||||
);
|
||||
}
|
||||
|
||||
public static ChannelCategory Empty { get; } = new(Snowflake.Zero, "Missing", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user