mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-24 03:36:52 -04:00
[CLI] Fix missing channel category bug when API returns empty string (#492)
This commit is contained in:
parent
8b9afe45b9
commit
e49cf997ea
2 changed files with 16 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue