Skip to content

Commit

Permalink
Update C_Console.GetAllCommands to ConsoleGetAllCommands for 10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
semlar committed Oct 14, 2023
1 parent 2338a29 commit ea9bd06
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cvars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1022,21 +1022,24 @@ local CategoryNames = { -- not sure how meaningful these really are (/Blizzard_C
}

--[[
C_Console.GetAllCommands() returns a list of tables in this format:
ConsoleGetAllCommands() returns a list of tables in this format:
category: number from 0 to 9 representing a category above
command: cvar name
commandType: 0 seems to represent a cvar, 1 is a script command (like quit)
help: cvar description text
--]]

-- C_Console.GetAllCommands is now ConsoleGetAllCommands as of 10.2.0
local ConsoleGetAllCommands = ConsoleGetAllCommands or C_Console and C_Console.GetAllCommands

function addon:CVarExists(cvar)
return not not select(2, pcall(function() return GetCVarInfo(cvar) end))
end

-- Returns filtered list of CVars
function addon:GetCVars()
local cvars = {}
for _, info in ipairs(C_Console.GetAllCommands()) do
for _, info in ipairs(ConsoleGetAllCommands()) do
if info.commandType == 0 -- cvar, rather than script
and info.category ~= 0 -- ignore debug category
and not strfind(info.command:lower(), 'debug') -- a number of commands with "debug" in their name are inexplicibly not in the "debug" category
Expand Down

0 comments on commit ea9bd06

Please sign in to comment.