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.
Dongle allows you to easily register slash commands using a very unique syntax. This allows you to define complex patterns to call methods and anonymous functions quite rapidly.
This API was introduced with Dongle-1.0
DongleObject Slash APIEdit
You can initialize multiple slash commands for the same DongleObject. Each of these returns a DongleSlashObject.
DongleObject:InitializeSlashCommand(desc, name, ...)Edit
Initializes a slash command object and returns it
- desc (string) - The root description of the slash command
- name (string) - A unique constant for your slash command. Historically this has been "ADDONNAME" in caps.
- ... - A list of actual slash commands you'd like to use for this command. These strings should not begin with "/".
- slashcmd (table) - The SlashCommand Object encapsulating the new slash command
The following creates the two slash commands, /praid and /perfectraid with the given description, tied to the constant "PERFECTRAID".
DongleObject:InitializeSlashCommand("PerfectRaid Slash Command", "PERFECTRAID", "praid", "perfectraid")
Dongle SlashCommand Object APIEdit
Each SlashCommand Object has access to the following methods:
SlashCommandObject:RegisterSlashHandler(desc, pattern, handler)Edit
Registers a slash command handler for a given lua string pattern.
- desc (string) - The usage description for this pattern
- pattern (string) - A lua pattern expression to match the arguments to the slash command
- handler (function, string) - A callback function, or a string representing a method name.
- If handler is specified as a string, the parser will look in the parent of the slash command for the handler. If the method isn't found, the slash command silently fails.
local cmd = DongleObject:InitializeSlashCommand("Hello World", "HELLOWORLD", "hellow") cmd:RegisterSlashHandler("Say Hello World!", "^$", "HelloWorld") cmd:RegisterSlashHandler("Say a custom hello message", "custom (%s+)", "HelloWorld") function DongleObject:HelloWorld(message) message = message or "Hello World" SendChatMessage(message, "SAY") end
We can now call /hellow and it will say "Hello World" in game. We could also call /hellow Hello Azeroth! and it will instead say "Hello Azeroth!" in game.
SlashCommandObject:InjectDBCommands(db, ... )Edit
Registers easy to use slash commands to manipulate or set profiles
- db (table) - Dongle Database for the profiles you want to be manipulated
- ... - Slash commands to inject, can be "copy", "delete", "list", "reset" or "set"
- Injects the passed slash commands for profile management which can be accessed through /slashCmd profile <command>
local cmd = DongleObject:InitializeSlashCommand("Hello World", "HELLOWORLD", "hellow") local db = DongleObject:InitializeDB( "HelloWorldDB", defaults ); cmd:InjectDBCommands( db, "copy", "list", "set" );
Adds /hellow profile copy, /hellow profile list and /hellow profile set to the list of slash command options.
Prints the usage statement of the given slash command.