diff options
| author | ilotterytea <iltsu@alright.party> | 2025-12-07 18:01:41 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-12-07 18:01:41 +0500 |
| commit | d4e3141dd7c32fdb2c1a1583fbd63079642d1447 (patch) | |
| tree | bac43d2188657f74c6f20cc3498e1f921f08410b | |
| parent | c2b77f1586851cdc472910ff42a38b90c23afa9a (diff) | |
feat: custom command aliases are retvrned back
| -rw-r--r-- | bot/src/handlers.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bot/src/handlers.cpp b/bot/src/handlers.cpp index 072c039..f473063 100644 --- a/bot/src/handlers.cpp +++ b/bot/src/handlers.cpp @@ -68,11 +68,14 @@ namespace bot::handlers { cid.size()); db::DatabaseRows cmds = conn->exec( - "SELECT name, message FROM custom_commands WHERE (name = $1 OR name " - "LIKE $2) " - "AND (channel_id " - "= $3 OR is_global = TRUE)", - {cid, cid_without_prefix, std::to_string(requester.channel.get_id())}); + "SELECT cc.name, cc.message FROM custom_commands cc " + "LEFT JOIN custom_command_aliases cca ON cca.command_id = cc.id " + "WHERE (cc.name = $1 OR cc.name " + "LIKE $2 OR cca.name = $3 OR cca.name LIKE $4) " + "AND (cc.channel_id " + "= $5 OR cc.is_global = TRUE)", + {cid, cid_without_prefix, cid, cid_without_prefix, + std::to_string(requester.channel.get_id())}); if (cmds.empty()) { return std::nullopt; |
