mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 03:06:53 -04:00
parent
1f5407f032
commit
bcf652edbe
2 changed files with 17 additions and 6 deletions
|
@ -20,8 +20,9 @@ public partial record Channel(
|
||||||
Snowflake? LastMessageId) : IHasId
|
Snowflake? LastMessageId) : IHasId
|
||||||
{
|
{
|
||||||
// Used for visual backwards-compatibility with old exports, where
|
// Used for visual backwards-compatibility with old exports, where
|
||||||
// channels without a parent (i.e. mostly DM channels) had a fallback
|
// channels without a parent (i.e. mostly DM channels) or channels
|
||||||
// category created for them.
|
// with an inaccessible parent (i.e. inside private categories) had
|
||||||
|
// a fallback category created for them.
|
||||||
public string Category => Parent?.Name ?? Kind switch
|
public string Category => Parent?.Name ?? Kind switch
|
||||||
{
|
{
|
||||||
ChannelKind.GuildCategory => "Category",
|
ChannelKind.GuildCategory => "Category",
|
||||||
|
|
|
@ -368,11 +368,21 @@ public class DiscordClient
|
||||||
.GetNonWhiteSpaceStringOrNull()?
|
.GetNonWhiteSpaceStringOrNull()?
|
||||||
.Pipe(Snowflake.Parse);
|
.Pipe(Snowflake.Parse);
|
||||||
|
|
||||||
var parent = parentId is not null
|
try
|
||||||
? await GetChannelAsync(parentId.Value, cancellationToken)
|
{
|
||||||
: null;
|
var parent = parentId is not null
|
||||||
|
? await GetChannelAsync(parentId.Value, cancellationToken)
|
||||||
|
: null;
|
||||||
|
|
||||||
return Channel.Parse(response, parent);
|
return Channel.Parse(response, parent);
|
||||||
|
}
|
||||||
|
// It's possible for the parent channel to be inaccessible, despite the
|
||||||
|
// child channel being accessible.
|
||||||
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1108
|
||||||
|
catch (DiscordChatExporterException)
|
||||||
|
{
|
||||||
|
return Channel.Parse(response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ValueTask<Message?> TryGetLastMessageAsync(
|
private async ValueTask<Message?> TryGetLastMessageAsync(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue