<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://addonstudio.org/mw1/index.php?action=history&amp;feed=atom&amp;title=WoW%3AUSERAPI_GetSlashFunc</id>
	<title>WoW:USERAPI GetSlashFunc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://addonstudio.org/mw1/index.php?action=history&amp;feed=atom&amp;title=WoW%3AUSERAPI_GetSlashFunc"/>
	<link rel="alternate" type="text/html" href="https://addonstudio.org/mw1/index.php?title=WoW:USERAPI_GetSlashFunc&amp;action=history"/>
	<updated>2026-05-22T14:37:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://addonstudio.org/mw1/index.php?title=WoW:USERAPI_GetSlashFunc&amp;diff=5329&amp;oldid=prev</id>
		<title>Move page script: Move page script moved page USERAPI GetSlashFunc to WoW:USERAPI GetSlashFunc without leaving a redirect</title>
		<link rel="alternate" type="text/html" href="https://addonstudio.org/mw1/index.php?title=WoW:USERAPI_GetSlashFunc&amp;diff=5329&amp;oldid=prev"/>
		<updated>2023-08-15T04:49:12Z</updated>

		<summary type="html">&lt;p&gt;Move page script moved page &lt;a href=&quot;/wiki/WoW:USERAPI_GetSlashFunc&quot; title=&quot;WoW:USERAPI GetSlashFunc&quot;&gt;USERAPI GetSlashFunc&lt;/a&gt; to &lt;a href=&quot;/wiki/WoW:USERAPI_GetSlashFunc&quot; title=&quot;WoW:USERAPI GetSlashFunc&quot;&gt;USERAPI GetSlashFunc&lt;/a&gt; without leaving a redirect&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:49, 15 August 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Move page script</name></author>
	</entry>
	<entry>
		<id>https://addonstudio.org/mw1/index.php?title=WoW:USERAPI_GetSlashFunc&amp;diff=5327&amp;oldid=prev</id>
		<title>Bear at 07:17, 18 May 2020</title>
		<link rel="alternate" type="text/html" href="https://addonstudio.org/mw1/index.php?title=WoW:USERAPI_GetSlashFunc&amp;diff=5327&amp;oldid=prev"/>
		<updated>2020-05-18T07:17:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:17, 18 May 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{userfunc}} &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;!-- Leave this line in! --&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{userfunc}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Returns the function called when using &amp;lt;code&amp;gt;/&amp;#039;&amp;#039;cmd&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Returns the function called when using &amp;lt;code&amp;gt;/&amp;#039;&amp;#039;cmd&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  slashFunction = {{PAGENAME}}(cmd)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  slashFunction = {{PAGENAME}}(cmd)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key addonstu_asmw2:diff::1.12:old-5328:rev-5327 --&gt;
&lt;/table&gt;</summary>
		<author><name>Bear</name></author>
	</entry>
	<entry>
		<id>https://addonstudio.org/mw1/index.php?title=WoW:USERAPI_GetSlashFunc&amp;diff=5328&amp;oldid=prev</id>
		<title>WoWWiki&gt;Egingell: Created page with &#039;{{userfunc}} &lt;!-- Leave this line in! --&gt;  Returns the function called when using &lt;code&gt;/&#039;&#039;cmd&#039;&#039;&lt;/code&gt;.  slashFunction = {{PAGENAME}}(cmd)  == Function Parameters == === Argumen…&#039;</title>
		<link rel="alternate" type="text/html" href="https://addonstudio.org/mw1/index.php?title=WoW:USERAPI_GetSlashFunc&amp;diff=5328&amp;oldid=prev"/>
		<updated>2009-10-19T23:42:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;{{userfunc}} &amp;lt;!-- Leave this line in! --&amp;gt;  Returns the function called when using &amp;lt;code&amp;gt;/&amp;#039;&amp;#039;cmd&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;.  slashFunction = {{PAGENAME}}(cmd)  == Function Parameters == === Argumen…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{userfunc}} &amp;lt;!-- Leave this line in! --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the function called when using &amp;lt;code&amp;gt;/&amp;#039;&amp;#039;cmd&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;.&lt;br /&gt;
 slashFunction = {{PAGENAME}}(cmd)&lt;br /&gt;
&lt;br /&gt;
== Function Parameters ==&lt;br /&gt;
=== Arguments ===&lt;br /&gt;
:(cmd)&lt;br /&gt;
:;cmd : the slash command to search for&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
:the actual function called when executing the &amp;#039;&amp;#039;cmd&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;local func = GetSlashFunc(&amp;quot;/quit&amp;quot;)&lt;br /&gt;
SLASH_MYQUIT1 = &amp;quot;/quit&amp;quot;&lt;br /&gt;
SLASH_MYQUIT2 = &amp;quot;/exit&amp;quot;&lt;br /&gt;
SlashCmdList[&amp;quot;MYQUIT&amp;quot;] = function(msg)&lt;br /&gt;
    if msg == &amp;quot;now&amp;quot; then&lt;br /&gt;
        ForceQuit()&lt;br /&gt;
    elseif func then&lt;br /&gt;
        func()&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Result==&lt;br /&gt;
: Quit now instead of in 30 seconds when &amp;lt;code&amp;gt;/quit now&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
 -- returns a slash command function on success or an &amp;#039;&amp;#039;informative&amp;#039;&amp;#039; error function on failure.&lt;br /&gt;
 local function GetSlashFunc(cmd)&lt;br /&gt;
     if not cmd then&lt;br /&gt;
         return function(cmd) print(&amp;quot;You must supply a command.&amp;quot;) end&lt;br /&gt;
     end&lt;br /&gt;
     if cmd:sub(1, 1) ~= &amp;quot;/&amp;quot; then&lt;br /&gt;
         cmd = &amp;quot;/&amp;quot; .. cmd&lt;br /&gt;
     end&lt;br /&gt;
     for id, val in pairs(_G) do&lt;br /&gt;
         if id:sub(1, 5) == &amp;quot;SLASH&amp;quot; and val == cmd then&lt;br /&gt;
             local slashID = id:match(&amp;quot;SLASH_(%a*)%d*&amp;quot;)&lt;br /&gt;
             return SlashCmdList[slashID]&lt;br /&gt;
         end&lt;br /&gt;
     end&lt;br /&gt;
     -- Didn&amp;#039;t find one?&lt;br /&gt;
     return function(cmd) print(cmd, &amp;quot;doesn&amp;#039;t exist.&amp;quot;) end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* This will not work to hook secure commands such as &amp;lt;code&amp;gt;/target&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/cast&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/focus&amp;lt;/code&amp;gt;, etc. The functions that are called with those commands are not globally accessible to addon scripts and, if they were, you would just end up breaking stuff.&lt;br /&gt;
* If an addon creates its slash command after yours, yours will no longer work (as per usual).&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>WoWWiki&gt;Egingell</name></author>
	</entry>
</feed>