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/notify.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'bot/src/modules/notify.hpp') diff --git a/bot/src/modules/notify.hpp b/bot/src/modules/notify.hpp index 3587e73..a25b34f 100644 --- a/bot/src/modules/notify.hpp +++ b/bot/src/modules/notify.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "../bundle.hpp" @@ -18,9 +17,8 @@ namespace bot { return {"sub", "unsub"}; } - 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); @@ -105,9 +103,10 @@ namespace bot { std::to_string(request.user.get_id())); work.commit(); - return bundle.localization - .get_formatted_line(request, loc::LineId::NotifySub, {t}) - .value(); + return command::Response( + bundle.localization + .get_formatted_line(request, loc::LineId::NotifySub, {t}) + .value()); } else if (subcommand_id == "unsub") { if (subs.empty()) { throw ResponseException( @@ -118,9 +117,10 @@ namespace bot { std::to_string(subs[0][0].as())); work.commit(); - return bundle.localization - .get_formatted_line(request, loc::LineId::NotifyUnsub, {t}) - .value(); + return command::Response( + bundle.localization + .get_formatted_line(request, loc::LineId::NotifyUnsub, {t}) + .value()); } throw ResponseException( -- cgit v1.2.3