From 52fd4ea8bad5cd7d3940a41df4f8f54b4e72beae Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 7 Dec 2024 17:24:25 +0500 Subject: feat: a special class for command responses --- bot/src/modules/custom_command.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'bot/src/modules/custom_command.hpp') diff --git a/bot/src/modules/custom_command.hpp b/bot/src/modules/custom_command.hpp index 50b3692..9fd1429 100644 --- a/bot/src/modules/custom_command.hpp +++ b/bot/src/modules/custom_command.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "../bundle.hpp" @@ -21,9 +20,8 @@ namespace bot { return {"new", "remove"}; } - std::variant, std::string> run( - const InstanceBundle &bundle, - const command::Request &request) const override { + command::Response run(const InstanceBundle &bundle, + const command::Request &request) const override { if (!request.subcommand_id.has_value()) { throw ResponseException( request, bundle.localization, command::SUBCOMMAND); @@ -68,10 +66,11 @@ namespace bot { "', '" + m + "')"); work.commit(); - return bundle.localization - .get_formatted_line(request, loc::LineId::CustomcommandNew, - {name}) - .value(); + return command::Response( + bundle.localization + .get_formatted_line(request, loc::LineId::CustomcommandNew, + {name}) + .value()); } else if (subcommand_id == "remove") { if (cmds.empty()) { throw ResponseException( @@ -82,10 +81,11 @@ namespace bot { std::to_string(cmds[0][0].as())); work.commit(); - return bundle.localization - .get_formatted_line(request, loc::LineId::CustomcommandDelete, - {name}) - .value(); + return command::Response( + bundle.localization + .get_formatted_line( + request, loc::LineId::CustomcommandDelete, {name}) + .value()); } throw ResponseException( -- cgit v1.2.3