diff --git a/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs b/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs index 44c48ab..e7febfc 100644 --- a/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs +++ b/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs @@ -105,7 +105,7 @@ public static class ExportWrapper if (message is null) { throw new InvalidOperationException( - $"Message #{messageId} does not exist in the export of channel #{channelId}." + $"Message #{messageId} not found in the export of channel #{channelId}." ); } @@ -129,7 +129,7 @@ public static class ExportWrapper if (message.ValueKind == JsonValueKind.Undefined) { throw new InvalidOperationException( - $"Message #{messageId} does not exist in the export of channel #{channelId}." + $"Message #{messageId} not found in the export of channel #{channelId}." ); } diff --git a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs index 660b67b..ce08726 100644 --- a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs @@ -169,8 +169,7 @@ public abstract class ExportCommandBase : DiscordCommandBase throw new CommandException( "Attempted to export multiple channels, but the output path is neither a directory nor a template. " + "If the provided output path is meant to be treated as a directory, make sure it ends with a slash. " - + "Provided output path: " - + OutputPath + + $"Provided output path: '{OutputPath}'." ); } diff --git a/DiscordChatExporter.Core/Discord/DiscordClient.cs b/DiscordChatExporter.Core/Discord/DiscordClient.cs index f87fdd3..a89ec22 100644 --- a/DiscordChatExporter.Core/Discord/DiscordClient.cs +++ b/DiscordChatExporter.Core/Discord/DiscordClient.cs @@ -618,7 +618,7 @@ public class DiscordClient if (!application.IsMessageContentIntentEnabled) { throw new DiscordChatExporterException( - "Bot account does not have the Message Content Intent enabled.", + "Provided bot account does not have the Message Content Intent enabled.", true ); } diff --git a/DiscordChatExporter.Core/Discord/Snowflake.cs b/DiscordChatExporter.Core/Discord/Snowflake.cs index e16031d..ad615df 100644 --- a/DiscordChatExporter.Core/Discord/Snowflake.cs +++ b/DiscordChatExporter.Core/Discord/Snowflake.cs @@ -22,26 +22,26 @@ public partial record struct Snowflake public static Snowflake FromDate(DateTimeOffset instant) => new(((ulong)instant.ToUnixTimeMilliseconds() - 1420070400000UL) << 22); - public static Snowflake? TryParse(string? str, IFormatProvider? formatProvider = null) + public static Snowflake? TryParse(string? value, IFormatProvider? formatProvider = null) { - if (string.IsNullOrWhiteSpace(str)) + if (string.IsNullOrWhiteSpace(value)) return null; // As number - if (ulong.TryParse(str, NumberStyles.None, formatProvider, out var value)) - return new Snowflake(value); + if (ulong.TryParse(value, NumberStyles.None, formatProvider, out var number)) + return new Snowflake(number); // As date - if (DateTimeOffset.TryParse(str, formatProvider, DateTimeStyles.None, out var instant)) + if (DateTimeOffset.TryParse(value, formatProvider, DateTimeStyles.None, out var instant)) return FromDate(instant); return null; } - public static Snowflake Parse(string str, IFormatProvider? formatProvider) => - TryParse(str, formatProvider) ?? throw new FormatException($"Invalid snowflake '{str}'."); + public static Snowflake Parse(string value, IFormatProvider? formatProvider) => + TryParse(value, formatProvider) ?? throw new FormatException($"Invalid snowflake '{value}'."); - public static Snowflake Parse(string str) => Parse(str, null); + public static Snowflake Parse(string value) => Parse(value, null); } public partial record struct Snowflake : IComparable, IComparable diff --git a/DiscordChatExporter.Core/Exporting/ChannelExporter.cs b/DiscordChatExporter.Core/Exporting/ChannelExporter.cs index f399299..fa6e895 100644 --- a/DiscordChatExporter.Core/Exporting/ChannelExporter.cs +++ b/DiscordChatExporter.Core/Exporting/ChannelExporter.cs @@ -22,7 +22,9 @@ public class ChannelExporter(DiscordClient discord) if (request.Channel.Kind == ChannelKind.GuildForum) { throw new DiscordChatExporterException( - $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) is a forum and cannot be exported directly. " + $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) " + + $"of guild '{request.Guild.Name}' (#{request.Guild.Id}) " + + $"is a forum and cannot be exported directly. " + "You need to pull its threads and export them individually." ); } @@ -31,7 +33,9 @@ public class ChannelExporter(DiscordClient discord) if (request.Channel.IsEmpty) { throw new DiscordChatExporterException( - $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) does not contain any messages." + $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) " + + $"of guild '{request.Guild.Name}' (#{request.Guild.Id}) " + + $"does not contain any messages." ); } @@ -39,7 +43,9 @@ public class ChannelExporter(DiscordClient discord) if (request.After is not null && !request.Channel.MayHaveMessagesAfter(request.After.Value)) { throw new DiscordChatExporterException( - $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) does not contain any messages within the specified period." + $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) " + + $"of guild '{request.Guild.Name}' (#{request.Guild.Id}) " + + $"does not contain any messages within the specified period." ); } @@ -50,7 +56,9 @@ public class ChannelExporter(DiscordClient discord) ) { throw new DiscordChatExporterException( - $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) does not contain any messages within the specified period." + $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) " + + $"of guild '{request.Guild.Name}' (#{request.Guild.Id}) " + + $"does not contain any messages within the specified period." ); } @@ -84,7 +92,9 @@ public class ChannelExporter(DiscordClient discord) { // Provide more context to the exception, to simplify debugging based on error messages throw new DiscordChatExporterException( - $"Failed to export message #{message.Id} in channel '{request.Channel.Name}' (#{request.Channel.Id}).", + $"Failed to export message #{message.Id} " + + $"in channel '{request.Channel.Name}' (#{request.Channel.Id}) " + + $"of guild '{request.Guild.Name} (#{request.Guild.Id})'.", ex is not DiscordChatExporterException dex || dex.IsFatal, ex ); @@ -95,7 +105,9 @@ public class ChannelExporter(DiscordClient discord) if (messageExporter.MessagesExported <= 0) { throw new DiscordChatExporterException( - $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) does not contain any matching messages within the specified period." + $"Channel '{request.Channel.Name}' (#{request.Channel.Id}) " + + $"of guild '{request.Guild.Name}' (#{request.Guild.Id}) " + + $"does not contain any matching messages within the specified period." ); } }