summaryrefslogtreecommitdiff
path: root/src/modules/help.hpp
blob: 13af22881fc17f95d39987289db3dfad536e7737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <string>
#include <variant>
#include <vector>

#include "../bundle.hpp"
#include "../commands/command.hpp"
#include "../commands/response_error.hpp"

namespace bot {
  namespace mod {
    class Help : public command::Command {
        std::string get_name() const override { return "help"; }

        std::variant<std::vector<std::string>, std::string> run(
            const InstanceBundle &bundle,
            const command::Request &request) const override {
          if (!bundle.configuration.url.help.has_value()) {
            throw ResponseException<ResponseError::ILLEGAL_COMMAND>(
                request, bundle.localization);
          }

          return bundle.localization
              .get_formatted_line(request, loc::LineId::HelpResponse,
                                  {*bundle.configuration.url.help})
              .value();
        }
    };
  }
}