mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-06-10 00:02:37 -06:00
Handle non-fatal exceptions in delete command
Import DiscordChatExporter.Core.Exceptions and switch from a generic catch to catching DiscordChatExporterException only when it's non-fatal (catch (DiscordChatExporterException ex) when (!ex.IsFatal)). This ensures fatal exceptions propagate while non-fatal errors are counted and reported. Also clarified the channel option description by removing the incorrect 'in DMs' note about deletions.
This commit is contained in:
parent
5ad979f69c
commit
47a163e982
|
|
@ -5,6 +5,7 @@ using CliFx.Binding;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Cli.Commands.Base;
|
using DiscordChatExporter.Cli.Commands.Base;
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
|
using DiscordChatExporter.Core.Exceptions;
|
||||||
using PowerKit.Extensions;
|
using PowerKit.Extensions;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
@ -15,7 +16,7 @@ public partial class DeleteMessagesCommand : DiscordCommandBase
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"channel",
|
"channel",
|
||||||
'c',
|
'c',
|
||||||
Description = "Channel ID. Note: You can only delete your own messages in DMs."
|
Description = "Channel ID. Note: You can only delete your own messages."
|
||||||
)]
|
)]
|
||||||
public required Snowflake ChannelId { get; set; }
|
public required Snowflake ChannelId { get; set; }
|
||||||
|
|
||||||
|
|
@ -137,7 +138,7 @@ public partial class DeleteMessagesCommand : DiscordCommandBase
|
||||||
|
|
||||||
// Discord's rate limit headers are handled automatically by DeleteMessageAsync
|
// Discord's rate limit headers are handled automatically by DeleteMessageAsync
|
||||||
}
|
}
|
||||||
catch
|
catch (DiscordChatExporterException ex) when (!ex.IsFatal)
|
||||||
{
|
{
|
||||||
failedCount++;
|
failedCount++;
|
||||||
using (console.WithForegroundColor(ConsoleColor.Red))
|
using (console.WithForegroundColor(ConsoleColor.Red))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue