From 3bd6378de82c4bd7bb8db8890c0e5d5d145c7036 Mon Sep 17 00:00:00 2001 From: shagu Date: Mon, 16 Nov 2020 15:21:07 +0100 Subject: [PATCH] api: add function to find slash commands --- api/api.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/api.lua b/api/api.lua index c3d9a8e9..b21623f3 100644 --- a/api/api.lua +++ b/api/api.lua @@ -164,6 +164,22 @@ function pfUI.api.modf(f) return math.ceil(f), mod(f,1) end +-- [ GetSlashCommands ] +-- Lists all registeres slash commands +-- 'text' [string] optional, a specific command to find +-- return: [list/bool] if +function pfUI.api.GetSlashCommands(text) + local cmds + for k, v in pairs(_G) do + if strfind(k, "^SLASH_") and (not text or v == text) then + cmds = cmds or {} + cmds[k] = v + end + end + + return cmds +end + -- [ GetCaptures ] -- Returns the indexes of a given regex pattern -- 'pat' [string] unformatted pattern