DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
CommandController.hpp
Go to the documentation of this file.
1/*
2 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3
4 Copyright 2021, 2022, 2023 Chris M. (RealTimeChris)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
20*/
21/// CommandController.hpp - Wrangler header for the command controller.
22/// May 20, 2021
23/// https://discordcoreapi.com
24/// \file CommandController.hpp
25
26#pragma once
27
30
31namespace DiscordCoreAPI {
32
33 /// \brief A class for handling commands from user input.
34 class DiscordCoreAPI_Dll CommandController {
35 public:
37
38 /// \brief Registers a function to be called.
39 /// \param functionNames A vector of strings to be accepted as function names.
40 /// \param baseFunction A unique_ptr to the function to be called.
41 void registerFunction(const std::vector<std::string>& functionNames, std::unique_ptr<BaseFunction> baseFunction);
42
43 /// \brief For returning the contained map of functions.
44 /// \returns A map containing the function names as well as unique_ptrs to the functions.
45 std::map<std::vector<std::string>, std::unique_ptr<BaseFunction>>& getFunctions();
46
47 CoRoutine<void> checkForAndRunCommand(CommandData commandData);
48
49 protected:
50 DiscordCoreClient* discordCoreClient{};
51
52 std::unique_ptr<BaseFunction> createFunction(const std::string& functionName);
53
54 std::unique_ptr<BaseFunction> getCommand(const std::string& commandName);
55 };
56
57};
The main namespace for this library.
A class for handling commands from user input.
A CoRoutine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:52
DiscordCoreClient - The main class for this library.
Command data, for functions executed by the CommandController.