diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-15 15:48:22 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-15 15:48:22 +0500 |
| commit | 2bd139d4323efa983df47bd131c90df501aee371 (patch) | |
| tree | b33dfddd1532389031c569b342f6f6974b728fb1 /bot/src/commands | |
| parent | 25477e58bd54585066f518a0e87317a7cd9a6632 (diff) | |
feat: get loaded commands from lua
Diffstat (limited to 'bot/src/commands')
| -rw-r--r-- | bot/src/commands/lua.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp index cab5cb4..4723311 100644 --- a/bot/src/commands/lua.cpp +++ b/bot/src/commands/lua.cpp @@ -84,6 +84,20 @@ namespace bot::command::lua { return bundle.irc_client.get_bot_username(); }); + state->set_function("bot_get_loaded_command_names", [state, &bundle]() { + sol::table o = state->create_table(); + + const std::vector<std::unique_ptr<Command>> &commands = + bundle.command_loader.get_commands(); + + std::for_each(commands.begin(), commands.end(), + [&o](const std::unique_ptr<Command> &command) { + o.add(command->get_name()); + }); + + return o; + }); + add_bot_library(state); } |
