Skip to content
everloot

Lore archive · Warcraft Wiki, 2023 dump

Dongle/Slash API

Last wiki revision 2007-06-07

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

You can initialize multiple slash commands for the same DongleObject. Each of these returns a DongleSlashObject.

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")

Each SlashCommand Object has access to the following methods:

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.

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

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.

Categories

  • Dongle

Source

https://warcraft.wiki.gg/wiki/Dongle/Slash_API · retrieved 2023-11-13 · CC BY-SA 4.0

Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.

This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.