From 0752ebac6128529ba9cb1d90349627f22dabdf85 Mon Sep 17 00:00:00 2001 From: huanmeng-qwq Date: Tue, 27 Aug 2024 13:31:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=82=E5=B8=B8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89message=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/command/litecommands/argument/ChannelArgument.java | 3 ++- .../impl/command/litecommands/argument/EmojiArgument.java | 3 ++- .../impl/command/litecommands/argument/GuildArgument.java | 3 ++- .../impl/command/litecommands/argument/RoleArgument.java | 3 ++- .../impl/command/litecommands/argument/UserArgument.java | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/snw/kookbc/impl/command/litecommands/argument/ChannelArgument.java b/src/main/java/snw/kookbc/impl/command/litecommands/argument/ChannelArgument.java index 8ef94dbc..0483f3d5 100644 --- a/src/main/java/snw/kookbc/impl/command/litecommands/argument/ChannelArgument.java +++ b/src/main/java/snw/kookbc/impl/command/litecommands/argument/ChannelArgument.java @@ -34,6 +34,7 @@ public class ChannelArgument extends ArgumentResolver { public static final MessageKey CHANNEL_NOT_FOUND = MessageKey.of("channel_not_found", "Channel not found"); + public static final MessageKey EMOJI_FOUND_FAILURE = MessageKey.of("emoji_found_failure", "Emoji found failure"); private final HttpAPI httpAPI; private final MessageRegistry messageRegistry; @@ -60,7 +61,7 @@ protected ParseResult parse(Invocation invocation, Argument } return ParseResult.success((T) channel); } catch (final Exception e) { - return ParseResult.failure(new CommandException("Channel not found", e)); + return ParseResult.failure(messageRegistry.getInvoked(EMOJI_FOUND_FAILURE, invocation, new CommandException("Channel not found", e))); } } diff --git a/src/main/java/snw/kookbc/impl/command/litecommands/argument/EmojiArgument.java b/src/main/java/snw/kookbc/impl/command/litecommands/argument/EmojiArgument.java index 065f2753..1e6c130d 100644 --- a/src/main/java/snw/kookbc/impl/command/litecommands/argument/EmojiArgument.java +++ b/src/main/java/snw/kookbc/impl/command/litecommands/argument/EmojiArgument.java @@ -49,6 +49,7 @@ public class EmojiArgument extends ArgumentResolver } return "Unsupported command"; }); + public static final MessageKey EMOJI_FOUND_FAILURE = MessageKey.of("emoji_found_failure", "Emoji found failure"); private final KBCClient client; private final MessageRegistry messageRegistry; @@ -105,7 +106,7 @@ protected ParseResult parse(Invocation invocation, A } return ParseResult.failure(messageRegistry.getInvoked(NOT_CHANNEL, invocation, message)); } catch (final Exception e) { - return ParseResult.failure(new CommandException("CustomEmoji not found", e)); + return ParseResult.failure(messageRegistry.getInvoked(EMOJI_FOUND_FAILURE, invocation, new CommandException("CustomEmoji not found", e))); } } diff --git a/src/main/java/snw/kookbc/impl/command/litecommands/argument/GuildArgument.java b/src/main/java/snw/kookbc/impl/command/litecommands/argument/GuildArgument.java index 443ad53d..3508a2c6 100644 --- a/src/main/java/snw/kookbc/impl/command/litecommands/argument/GuildArgument.java +++ b/src/main/java/snw/kookbc/impl/command/litecommands/argument/GuildArgument.java @@ -33,6 +33,7 @@ public class GuildArgument extends ArgumentResolver { public static final MessageKey GUILD_NOT_FOUND = MessageKey.of("guild_not_found", "Guild not found"); + public static final MessageKey GUILD_FOUND_FAILURE = MessageKey.of("guild_found_failure", "Guild found failure"); private final HttpAPI httpAPI; private final MessageRegistry messageRegistry; @@ -52,7 +53,7 @@ protected ParseResult parse(Invocation invocation, Argumen } return ParseResult.success(guild); } catch (final Exception e) { - return ParseResult.failure(new CommandException("Guild not found", e)); + return ParseResult.failure(messageRegistry.getInvoked(GUILD_FOUND_FAILURE, invocation, new CommandException("Guild not found", e))); } } diff --git a/src/main/java/snw/kookbc/impl/command/litecommands/argument/RoleArgument.java b/src/main/java/snw/kookbc/impl/command/litecommands/argument/RoleArgument.java index c0a0eaac..cac22bb8 100644 --- a/src/main/java/snw/kookbc/impl/command/litecommands/argument/RoleArgument.java +++ b/src/main/java/snw/kookbc/impl/command/litecommands/argument/RoleArgument.java @@ -49,6 +49,7 @@ public class RoleArgument extends ArgumentResolver { } return "Unsupported command"; }); + public static final MessageKey ROLE_FOUND_FAILURE = MessageKey.of("role_found_failure", "Role found failure"); private final KBCClient client; private final MessageRegistry messageRegistry; @@ -102,7 +103,7 @@ protected ParseResult parse(Invocation invocation, Argument } return ParseResult.failure(messageRegistry.getInvoked(NOT_CHANNEL, invocation, message)); } catch (final Exception e) { - return ParseResult.failure(new CommandException("Role not found", e)); + return ParseResult.failure(messageRegistry.getInvoked(ROLE_FOUND_FAILURE, invocation, new CommandException("Role not found", e))); } } diff --git a/src/main/java/snw/kookbc/impl/command/litecommands/argument/UserArgument.java b/src/main/java/snw/kookbc/impl/command/litecommands/argument/UserArgument.java index 09d811e5..a9a6cd58 100644 --- a/src/main/java/snw/kookbc/impl/command/litecommands/argument/UserArgument.java +++ b/src/main/java/snw/kookbc/impl/command/litecommands/argument/UserArgument.java @@ -33,6 +33,7 @@ public class UserArgument extends ArgumentResolver { public static final MessageKey USER_NOT_FOUND = MessageKey.of("user_not_found", "User not found"); + public static final MessageKey USER_FOUND_FAILURE = MessageKey.of("user_found_failure", "User found failure"); private final HttpAPI httpAPI; private final MessageRegistry messageRegistry; @@ -58,7 +59,7 @@ protected ParseResult parse(Invocation invocation, Argument } return ParseResult.success(user); } catch (final Exception e) { - return ParseResult.failure(new CommandException("User not found", e)); + return ParseResult.failure(messageRegistry.getInvoked(USER_FOUND_FAILURE, invocation, new CommandException("User not found", e))); } }