summaryrefslogtreecommitdiff
path: root/bot/src/modules/timer.hpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-12-07 17:24:25 +0500
committerilotterytea <iltsu@alright.party>2024-12-07 17:24:25 +0500
commit52fd4ea8bad5cd7d3940a41df4f8f54b4e72beae (patch)
tree28f13892e7da8ec023f4b4d1113bef88795724ca /bot/src/modules/timer.hpp
parente604d12282b8fa9f9023bb79161b36c9a8b0be55 (diff)
feat: a special class for command responses
Diffstat (limited to 'bot/src/modules/timer.hpp')
-rw-r--r--bot/src/modules/timer.hpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/bot/src/modules/timer.hpp b/bot/src/modules/timer.hpp
index 36c3982..5fd3549 100644
--- a/bot/src/modules/timer.hpp
+++ b/bot/src/modules/timer.hpp
@@ -1,7 +1,6 @@
#pragma once
#include <string>
-#include <variant>
#include <vector>
#include "../bundle.hpp"
@@ -21,9 +20,8 @@ namespace bot {
return {"new", "remove"};
}
- std::variant<std::vector<std::string>, 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<NOT_ENOUGH_ARGUMENTS>(
request, bundle.localization, command::SUBCOMMAND);
@@ -86,9 +84,10 @@ namespace bot {
"', '" + m + "', " + std::to_string(interval_s) + ")");
work.commit();
- return bundle.localization
- .get_formatted_line(request, loc::LineId::TimerNew, {name})
- .value();
+ return command::Response(
+ bundle.localization
+ .get_formatted_line(request, loc::LineId::TimerNew, {name})
+ .value());
} else if (subcommand_id == "remove") {
if (timers.empty()) {
throw ResponseException<ResponseError::NOT_FOUND>(
@@ -99,9 +98,11 @@ namespace bot {
std::to_string(timers[0][0].as<int>()));
work.commit();
- return bundle.localization
- .get_formatted_line(request, loc::LineId::TimerDelete, {name})
- .value();
+ return command::Response(
+ bundle.localization
+ .get_formatted_line(request, loc::LineId::TimerDelete,
+ {name})
+ .value());
}
throw ResponseException<ResponseError::SOMETHING_WENT_WRONG>(