diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-06 17:28:47 +0400 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-06 17:28:47 +0400 |
| commit | 2a49844a95593ac98e919c18651320e62f276fa7 (patch) | |
| tree | 01b7e2ebb1dc7a9ac92e7c3105edfd098271f29a /bot/src/commands/request.cpp | |
| parent | a1a36cf4d4999b5ce89dce95364c9fd839b54b5d (diff) | |
feat: implementing lua coding
Diffstat (limited to 'bot/src/commands/request.cpp')
| -rw-r--r-- | bot/src/commands/request.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bot/src/commands/request.cpp b/bot/src/commands/request.cpp new file mode 100644 index 0000000..7acc107 --- /dev/null +++ b/bot/src/commands/request.cpp @@ -0,0 +1,28 @@ +#include "commands/request.hpp" + +#include <sol/types.hpp> + +namespace bot::command { + sol::table Request::as_lua_table(std::shared_ptr<sol::state> luaState) const { + sol::table o = luaState->create_table(); + + o["command_id"] = this->command_id; + if (this->subcommand_id.has_value()) { + o["subcommand_id"] = this->subcommand_id.value(); + } else { + o["subcommand_id"] = sol::lua_nil; + } + if (this->message.has_value()) { + o["message"] = this->message.value(); + } else { + o["message"] = sol::lua_nil; + } + + o["sender"] = this->user.as_lua_table(luaState); + o["channel"] = this->channel.as_lua_table(luaState); + o["channel_preference"] = this->channel_preferences.as_lua_table(luaState); + o["rights"] = this->user_rights.as_lua_table(luaState); + + return o; + } +}
\ No newline at end of file |
