Fandom

WoWWiki

USERAPI SlashCmdList AddSlashCommand

Redirected from SlashCmdList AddSlashCommand

104,642pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

This page documents a user-defined function that you can copy and paste into your addon. Replace <PREFIX> with your AddOn's prefix to avoid conflicts between different versions of these functions.
User defined functions < SlashCmdList AddSlashCommand

Add slash commands.

SlashCmdList_AddSlashCommand(name, func, ...)

Function Parameters Edit

Arguments Edit

name 
Unique identifier (e.g. MYADDON_SLASHCMD)
func 
The function (variable or actual function)
... 
A list of commands with or without the leading slash

Returns Edit

nil

Example Edit

The following snippets do the same thing.

SlashCmdList_AddSlashCommand('MYADDON_SLASHCMD', function(msg)
    DEFAULT_CHAT_FRAME:AddMessage(msg or 'nil')
end, 'myaddon', 'ma')
SlashCmdList['MYADDON_SLASHCMD'] = function(msg)
    DEFAULT_CHAT_FRAME:AddMessage(msg or 'nil')
end
SLASH_MYADDON_SLASHCMD1 = '/myaddon'
SLASH_MYADDON_SLASHCMD2 = '/ma'

CodeEdit

function SlashCmdList_AddSlashCommand(name, func, ...)
    SlashCmdList[name] = func
    local command = ''
    for i = 1, select('#', ...) do
        command = select(i, ...)
        if strsub(command, 1, 1) ~= '/' then
            command = '/' .. command
        end
        _G['SLASH_'..name..i] = command
    end
end

Also on Fandom

Random Wiki