diff --git a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs index b43d190..ee021ba 100644 --- a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs @@ -25,7 +25,6 @@ public class ExportGuildCommand : ExportCommandBase )] public bool IncludeVoiceChannels { get; init; } = true; - public override async ValueTask ExecuteAsync(IConsole console) { await base.ExecuteAsync(console); diff --git a/DiscordChatExporter.Core/Discord/DiscordClient.cs b/DiscordChatExporter.Core/Discord/DiscordClient.cs index 46c856a..b112ec2 100644 --- a/DiscordChatExporter.Core/Discord/DiscordClient.cs +++ b/DiscordChatExporter.Core/Discord/DiscordClient.cs @@ -215,7 +215,7 @@ public class DiscordClient var channelsJson = response .EnumerateArray() - .OrderBy(c => c.GetProperty("position").GetInt32()) + .OrderBy(j => j.GetProperty("position").GetInt32()) .ThenBy(j => j.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse)) .ToArray(); @@ -349,7 +349,7 @@ public class DiscordClient return response?.Pipe(j => Member.Parse(j, guildId)); } - public async ValueTask TryGetGuildInviteAsync( + public async ValueTask TryGetInviteAsync( string code, CancellationToken cancellationToken = default) { @@ -357,33 +357,24 @@ public class DiscordClient return response?.Pipe(Invite.Parse); } - public async ValueTask TryGetChannelAsync( + public async ValueTask GetChannelAsync( Snowflake channelId, CancellationToken cancellationToken = default) { - var response = await TryGetJsonResponseAsync($"channels/{channelId}", cancellationToken); - if (response is null) - return null; + var response = await GetJsonResponseAsync($"channels/{channelId}", cancellationToken); var parentId = response - .Value .GetPropertyOrNull("parent_id")? .GetNonWhiteSpaceStringOrNull()? .Pipe(Snowflake.Parse); var parent = parentId is not null - ? await TryGetChannelAsync(parentId.Value, cancellationToken) + ? await GetChannelAsync(parentId.Value, cancellationToken) : null; - return Channel.Parse(response.Value, parent); + return Channel.Parse(response, parent); } - public async ValueTask GetChannelAsync( - Snowflake channelId, - CancellationToken cancellationToken = default) => - await TryGetChannelAsync(channelId, cancellationToken) ?? - throw new InvalidOperationException($"Channel {channelId} not found."); - private async ValueTask TryGetLastMessageAsync( Snowflake channelId, Snowflake? before = null, diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index 947c1ef..661bd13 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -321,7 +321,7 @@ foreach (var inviteCode in inviteCodes) { - var invite = await Context.Discord.TryGetGuildInviteAsync(inviteCode, CancellationToken); + var invite = await Context.Discord.TryGetInviteAsync(inviteCode, CancellationToken); if (invite is null) { continue;