summaryrefslogtreecommitdiff
path: root/bot/src/modules/help.hpp
blob: 1341b86d6f9f561adffec29c0bb00fbed978f4af (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
#pragma once

#include <string>
#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"; }

        command::Response 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 command::Response(
              bundle.localization
                  .get_formatted_line(request, loc::LineId::HelpResponse,
                                      {*bundle.configuration.url.help})
                  .value());
        }
    };
  }
}