Archived
help message bug fixes 1
This commit is contained in:
1 parent
6341f57d6c
commit
6ddc30483e
51 files changed
+439
-434
No files matched your search
+16
-16
@@ -23,7 +23,7 @@
|
||||
<a href="#documentation" id="documentation" style="color: inherit; text-decoration: none;">
|
||||
<h2>Documentation</h2>
|
||||
</a>
|
||||
<p>Reference for available objects and structures is available <a href="https://grz4na.github.io/commandbot/"><strong>here</strong></a>. All descriptions can also be accessed from your code editor/IDE. TypeScript declaration files are also included (.d.ts) for some programs (like Visual Studio Code) to give autocompletion suggestions.</p>
|
||||
<p>Reference for available objects and structures is available <a href="https://grz4na.github.io/CommandBot/index.html"><strong>here</strong></a>. All descriptions can also be accessed from your code editor/IDE. TypeScript declaration files are also included (.d.ts) for some programs (like Visual Studio Code) to give autocompletion suggestions.</p>
|
||||
|
||||
<a href="#table-of-contents" id="table-of-contents" style="color: inherit; text-decoration: none;">
|
||||
<h2>Table of contents</h2>
|
||||
@@ -106,9 +106,9 @@
|
||||
<pre><code class="language-javascript"><span class="hl-0">// CommonJS</span><br/><span class="hl-3">const</span><span class="hl-2"> { </span><span class="hl-4">Bot</span><span class="hl-2"> } = </span><span class="hl-5">require</span><span class="hl-2">(</span><span class="hl-6">"commandbot"</span><span class="hl-2">);</span><br/><br/><span class="hl-0">// ES Modules (to use ESM add "type": "module" to package.json file)</span><br/><span class="hl-7">import</span><span class="hl-2"> { </span><span class="hl-1">Bot</span><span class="hl-2"> } </span><span class="hl-7">from</span><span class="hl-2"> </span><span class="hl-6">"commandbot"</span><span class="hl-2">;</span>
|
||||
</code></pre>
|
||||
<ol start="6">
|
||||
<li>Initialize the bot instance (<a href="https://grz4na.github.io/commandbot/interfaces/InitOptions.html">InitOptions</a>) (list of available intents <a href="https://discord.js.org/#/docs/main/stable/class/Intents?scrollTo=s-FLAGS">here</a>)</li>
|
||||
<li>Initialize the bot instance (<a href="https://grz4na.github.io/CommandBot/interfaces/InitOptions.html">InitOptions</a>) (list of available intents <a href="https://discord.js.org/#/docs/main/stable/class/Intents?scrollTo=s-FLAGS">here</a>)</li>
|
||||
</ol>
|
||||
<pre><code class="language-javascript"><span class="hl-3">const</span><span class="hl-2"> </span><span class="hl-4">bot</span><span class="hl-2"> = </span><span class="hl-3">new</span><span class="hl-2"> </span><span class="hl-5">Bot</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-1">name:</span><span class="hl-2"> </span><span class="hl-6">"YOUR_BOT_NAME"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">globalPrefix:</span><span class="hl-2"> </span><span class="hl-6">"!"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">argumentSeparator:</span><span class="hl-2"> </span><span class="hl-6">","</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">commandSeparator:</span><span class="hl-2"> </span><span class="hl-6">"/"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">clientOptions:</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">intents:</span><span class="hl-2"> [...</span><span class="hl-6">"DISCORD_API_INTENTS"</span><span class="hl-2">],</span><br/><span class="hl-2"> },</span><br/><span class="hl-2"> </span><span class="hl-1">token:</span><span class="hl-2"> </span><span class="hl-6">"DISCORD_BOT_TOKEN"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">applicationId:</span><span class="hl-2"> </span><span class="hl-6">"APPLICATION_ID"</span><span class="hl-2">,</span><br/><span class="hl-2">});</span>
|
||||
<pre><code class="language-javascript"><span class="hl-3">const</span><span class="hl-2"> </span><span class="hl-4">bot</span><span class="hl-2"> = </span><span class="hl-3">new</span><span class="hl-2"> </span><span class="hl-5">Bot</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-1">name:</span><span class="hl-2"> </span><span class="hl-6">"YOUR_BOT_NAME"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">globalPrefix:</span><span class="hl-2"> </span><span class="hl-6">"!"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">argumentSeparator:</span><span class="hl-2"> </span><span class="hl-6">","</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">commandSeparator:</span><span class="hl-2"> </span><span class="hl-6">"/"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">clientOptions:</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">intents:</span><span class="hl-2"> [...</span><span class="hl-6">"DISCORD_API_INTENTS"</span><span class="hl-2">],</span><br/><span class="hl-2"> },</span><br/><span class="hl-2"> </span><span class="hl-1">token:</span><span class="hl-2"> </span><span class="hl-6">"DISCORD_BOT_TOKEN"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">applicationId:</span><span class="hl-2"> </span><span class="hl-6">"APPLICATION_ID"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">help:</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">enabled:</span><span class="hl-2"> </span><span class="hl-3">true</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">title:</span><span class="hl-2"> </span><span class="hl-6">"List of commands"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">usage:</span><span class="hl-2"> </span><span class="hl-6">"[command name]"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">description:</span><span class="hl-2"> </span><span class="hl-6">"Show all commands available to use in my fantastic Discord bot."</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">bottomText:</span><span class="hl-2"> </span><span class="hl-6">"Hello World"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">color:</span><span class="hl-2"> </span><span class="hl-6">"#0055ff"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">visible:</span><span class="hl-2"> </span><span class="hl-3">false</span><span class="hl-2">,</span><br/><span class="hl-2"> },</span><br/><span class="hl-2">});</span>
|
||||
</code></pre>
|
||||
<ol start="7">
|
||||
<li>Create and add commands to the <em>Bot</em> instance (see <a href="#commands">Commands</a>)</li>
|
||||
@@ -127,17 +127,17 @@
|
||||
<a href="#creating-a-command" id="creating-a-command" style="color: inherit; text-decoration: none;">
|
||||
<h2>Creating a command</h2>
|
||||
</a>
|
||||
<p>To create a command, use <em><a href="https://grz4na.github.io/commandbot/classes/CommandManager.html#add">CommandManager.prototype.add</a></em> method</p>
|
||||
<p>To create a command, use <em><a href="https://grz4na.github.io/CommandBot/classes/CommandManager.html#add">CommandManager.prototype.add</a></em> method</p>
|
||||
<p>Command types</p>
|
||||
<ul>
|
||||
<li><a href="https://grz4na.github.io/commandbot/interfaces/ChatCommandInit.html">CHAT</a> - message interactions using command prefixes or slash commands</li>
|
||||
<li><a href="https://grz4na.github.io/commandbot/interfaces/ContextMenuCommandInit.html">USER</a> - right-click context menu interactions on users</li>
|
||||
<li><a href="https://grz4na.github.io/commandbot/interfaces/ContextMenuCommandInit.html">MESSAGE</a> - right-click context menu interactions on messages</li>
|
||||
<li><a href="https://grz4na.github.io/CommandBot/interfaces/ChatCommandInit.html">CHAT</a> - message interactions using command prefixes or slash commands</li>
|
||||
<li><a href="https://grz4na.github.io/CommandBot/interfaces/ContextMenuCommandInit.html">USER</a> - right-click context menu interactions on users</li>
|
||||
<li><a href="https://grz4na.github.io/CommandBot/interfaces/ContextMenuCommandInit.html">MESSAGE</a> - right-click context menu interactions on messages</li>
|
||||
</ul>
|
||||
<p>Chat command example:</p>
|
||||
<pre><code class="language-javascript"><span class="hl-1">bot</span><span class="hl-2">.</span><span class="hl-1">commands</span><span class="hl-2">.</span><span class="hl-5">add</span><span class="hl-2">(</span><span class="hl-6">"CHAT"</span><span class="hl-2">, {</span><br/><span class="hl-2"> </span><span class="hl-1">name:</span><span class="hl-2"> </span><span class="hl-6">"greet"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">parameters:</span><span class="hl-2"> [</span><br/><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">name:</span><span class="hl-2"> </span><span class="hl-6">"user"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">description:</span><span class="hl-2"> </span><span class="hl-6">"User to greet"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">optional:</span><span class="hl-2"> </span><span class="hl-3">false</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">type:</span><span class="hl-2"> </span><span class="hl-6">"user"</span><span class="hl-2">,</span><br/><span class="hl-2"> },</span><br/><span class="hl-2"> ],</span><br/><span class="hl-2"> </span><span class="hl-1">aliases:</span><span class="hl-2"> [</span><span class="hl-6">"hello"</span><span class="hl-2">],</span><br/><span class="hl-2"> </span><span class="hl-1">description:</span><span class="hl-2"> </span><span class="hl-6">"Welcome someone to your server"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">usage:</span><span class="hl-2"> </span><span class="hl-6">"[user]"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">dm:</span><span class="hl-2"> </span><span class="hl-3">false</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">guilds:</span><span class="hl-2"> [</span><span class="hl-6">"123456789874561230"</span><span class="hl-2">],</span><br/><span class="hl-2"> </span><span class="hl-1">slash:</span><span class="hl-2"> </span><span class="hl-3">true</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">visible:</span><span class="hl-2"> </span><span class="hl-3">true</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">permissions:</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">resolvable:</span><span class="hl-2"> [</span><span class="hl-6">"ADMINISTRATOR"</span><span class="hl-2">],</span><br/><span class="hl-2"> </span><span class="hl-1">checkType:</span><span class="hl-2"> </span><span class="hl-6">"ANY"</span><span class="hl-2">,</span><br/><span class="hl-2"> },</span><br/><span class="hl-2"> </span><span class="hl-5">function</span><span class="hl-1">:</span><span class="hl-2"> </span><span class="hl-3">async</span><span class="hl-2"> (</span><span class="hl-1">i</span><span class="hl-2">) </span><span class="hl-3">=></span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-3">const</span><span class="hl-2"> </span><span class="hl-4">user</span><span class="hl-2"> = </span><span class="hl-7">await</span><span class="hl-2"> </span><span class="hl-1">i</span><span class="hl-2">.</span><span class="hl-5">get</span><span class="hl-2">(</span><span class="hl-6">"user"</span><span class="hl-2">).</span><span class="hl-5">toObject</span><span class="hl-2">();</span><br/><span class="hl-2"> </span><span class="hl-7">return</span><span class="hl-2"> </span><span class="hl-6">`Hello </span><span class="hl-3">${</span><span class="hl-1">user</span><span class="hl-8">.</span><span class="hl-5">toString</span><span class="hl-8">()</span><span class="hl-3">}</span><span class="hl-6">`</span><span class="hl-2">;</span><br/><span class="hl-2"> },</span><br/><span class="hl-2">});</span>
|
||||
</code></pre>
|
||||
<p>Command function schema is defined <strong><a href="https://grz4na.github.io/commandbot/modules.html#CommandFunction">here</a></strong></p>
|
||||
<p>Command function schema is defined <strong><a href="https://grz4na.github.io/CommandBot/modules.html#CommandFunction">here</a></strong></p>
|
||||
|
||||
<a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
|
||||
<h2>Parameters</h2>
|
||||
@@ -147,15 +147,15 @@
|
||||
<h3>Types</h3>
|
||||
</a>
|
||||
<ul>
|
||||
<li><a href="https://grz4na.github.io/commandbot/modules.html#ParameterType">primitive</a></li>
|
||||
<li><a href="https://grz4na.github.io/commandbot/modules.html#ObjectIdType">objects</a></li>
|
||||
<li><a href="https://grz4na.github.io/CommandBot/modules.html#ParameterType">primitive</a></li>
|
||||
<li><a href="https://grz4na.github.io/CommandBot/modules.html#ObjectIdType">objects</a></li>
|
||||
</ul>
|
||||
<p>To get an entity ID from <em>ObjectID</em> use the <em><a href="https://grz4na.github.io/commandbot/classes/ObjectID.html#id">id</a></em> property. You can also call <em><a href="https://grz4na.github.io/commandbot/classes/ObjectID.html#toObject">toObject</a></em> method to retrieve full entity object from Discord API</p>
|
||||
<p>To get an entity ID from <em>ObjectID</em> use the <em><a href="https://grz4na.github.io/CommandBot/classes/ObjectID.html#id">id</a></em> property. You can also call <em><a href="https://grz4na.github.io/CommandBot/classes/ObjectID.html#toObject">toObject</a></em> method to retrieve full entity object from Discord API</p>
|
||||
|
||||
<a href="#defining" id="defining" style="color: inherit; text-decoration: none;">
|
||||
<h3>Defining</h3>
|
||||
</a>
|
||||
<p>Pass a list of <em><a href="https://grz4na.github.io/commandbot/interfaces/ParameterSchema.html">ParameterSchema</a></em> objects to <em><a href="https://grz4na.github.io/commandbot/interfaces/ChatCommandInit.html#parameters">parameters</a></em> property</p>
|
||||
<p>Pass a list of <em><a href="https://grz4na.github.io/CommandBot/interfaces/ParameterSchema.html">ParameterSchema</a></em> objects to <em><a href="https://grz4na.github.io/CommandBot/interfaces/ChatCommandInit.html#parameters">parameters</a></em> property</p>
|
||||
<p>Example parameter object:</p>
|
||||
<pre><code class="language-javascript"><span class="hl-2">{</span><br/><span class="hl-2"> </span><span class="hl-9">name</span><span class="hl-2">: </span><span class="hl-6">"user"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-9">description</span><span class="hl-2">: </span><span class="hl-6">"User to mention"</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-9">optional</span><span class="hl-2">: </span><span class="hl-3">false</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-9">type</span><span class="hl-2">: </span><span class="hl-6">"user"</span><br/><span class="hl-2">}</span>
|
||||
</code></pre>
|
||||
@@ -163,7 +163,7 @@
|
||||
<a href="#reading-input-value" id="reading-input-value" style="color: inherit; text-decoration: none;">
|
||||
<h3>Reading input value</h3>
|
||||
</a>
|
||||
<p>To read parameter values use <em><a href="https://grz4na.github.io/commandbot/classes/InputManager.html#get">InputManager.prototype.get()</a></em> (passed in the first argument of a command function)</p>
|
||||
<p>To read parameter values use <em><a href="https://grz4na.github.io/CommandBot/classes/InputManager.html#get">InputManager.prototype.get()</a></em> (passed in the first argument of a command function)</p>
|
||||
<p>Example:</p>
|
||||
<pre><code class="language-javascript"><span class="hl-3">function</span><span class="hl-2">: (</span><span class="hl-1">i</span><span class="hl-2">) </span><span class="hl-3">=></span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-10">const</span><span class="hl-2"> </span><span class="hl-1">userObj</span><span class="hl-2"> = </span><span class="hl-1">i</span><span class="hl-2">.</span><span class="hl-5">get</span><span class="hl-2">(</span><span class="hl-6">'member'</span><span class="hl-2">, </span><span class="hl-6">'user'</span><span class="hl-2">)</span><br/><span class="hl-2"> </span><span class="hl-5">if</span><span class="hl-2">(</span><span class="hl-1">userObj</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-3">const</span><span class="hl-2"> </span><span class="hl-4">user</span><span class="hl-2"> = </span><span class="hl-1">userObj</span><span class="hl-2">.</span><span class="hl-5">toObject</span><span class="hl-2">();</span><br/><span class="hl-2"> </span><span class="hl-7">if</span><span class="hl-2">(</span><span class="hl-1">user</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-7">return</span><span class="hl-2"> </span><span class="hl-6">`Hello, </span><span class="hl-3">${</span><span class="hl-1">user</span><span class="hl-8">.</span><span class="hl-5">toString</span><span class="hl-8">()</span><span class="hl-3">}</span><span class="hl-6">`</span><br/><span class="hl-2"> }</span><br/><span class="hl-2"> </span><span class="hl-7">else</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-7">throw</span><span class="hl-2"> </span><span class="hl-3">new</span><span class="hl-2"> </span><span class="hl-10">Error</span><span class="hl-2">(</span><span class="hl-6">'User not found'</span><span class="hl-2">)</span><br/><span class="hl-2"> }</span><br/><span class="hl-2"> }</span><br/><span class="hl-2">}</span>
|
||||
</code></pre>
|
||||
@@ -171,7 +171,7 @@
|
||||
<a href="#events" id="events" style="color: inherit; text-decoration: none;">
|
||||
<h1>Events</h1>
|
||||
</a>
|
||||
<p>CommandBot is using <em><a href="https://nodejs.org/api/events.html">EventEmitter</a></em> that is built into Node.js. You can listen to events using the <em><a href="https://grz4na.github.io/commandbot/classes/Bot.html#on-1">on</a></em> method. Event types are available <strong><a href="https://grz4na.github.io/commandbot/classes/Bot.html#on-1">here</a></strong>.</p>
|
||||
<p>CommandBot is using <em><a href="https://nodejs.org/api/events.html">EventEmitter</a></em> that is built into Node.js. You can listen to events using the <em><a href="https://grz4na.github.io/CommandBot/classes/Bot.html#on-1">on</a></em> method. Event types are available <strong><a href="https://grz4na.github.io/CommandBot/classes/Bot.html#on-1">here</a></strong>.</p>
|
||||
|
||||
<a href="#messages" id="messages" style="color: inherit; text-decoration: none;">
|
||||
<h1>Messages</h1>
|
||||
@@ -180,12 +180,12 @@
|
||||
<a href="#system-messages" id="system-messages" style="color: inherit; text-decoration: none;">
|
||||
<h2>System messages</h2>
|
||||
</a>
|
||||
<p>System messages can be composed and sent automatically when a certain action happens. All message types are available <strong><a href="">here</a></strong>. Their configuration is stored in <em><a href="https://grz4na.github.io/commandbot/classes/Bot.html#messages">Bot.prototype.messages.system</a></em> property. Each of these messages can be customized with <em><a href="https://github.com/GRZ4NA/CommandBot/issues/interfaces/SystemMessageAppearance.html">SystemMessageAppearance</a></em> objects. There is also a global <em><a href="https://grz4na.github.io/commandbot/classes/SystemMessageManager.html#deleteTimeout">deleteTimeout</a></em> property so messages can automatically be deleted after a given time.</p>
|
||||
<p>System messages can be composed and sent automatically when a certain action happens. All message types are available <strong><a href="https://grz4na.github.io/CommandBot/classes/SystemMessageManager.html#ERROR">here</a></strong>. Their configuration is stored in <em><a href="https://grz4na.github.io/CommandBot/classes/Bot.html#messages">Bot.prototype.messages</a></em> property. Each of these messages can be customized with <em><a href="https://github.com/GRZ4NA/CommandBot/issues/interfaces/SystemMessageAppearance.html">SystemMessageAppearance</a></em> objects. There is also a global <em><a href="https://grz4na.github.io/CommandBot/classes/SystemMessageManager.html#deleteTimeout">deleteTimeout</a></em> property so messages can automatically be deleted after a given time.</p>
|
||||
|
||||
<a href="#help-message" id="help-message" style="color: inherit; text-decoration: none;">
|
||||
<h2>Help message</h2>
|
||||
</a>
|
||||
<p>Its configuration is stored in <em><a href="https://grz4na.github.io/commandbot/classes/Bot.html#messages">Bot.prototype.messages.help</a></em> property and can be customized with <em><a href="https://grz4na.github.io/commandbot/interfaces/HelpMessageParams.html">HelpMessageParams</a></em> object.</p>
|
||||
<p>To configure it use the <em><a href="https://grz4na.github.io/CommandBot/interfaces/InitOptions.html#help">help</a></em> property in the bot's constructor and pass there a <em><a href="https://grz4na.github.io/CommandBot/interfaces/HelpMessageParams.html">HelpMessageParams</a></em> object.</p>
|
||||
<blockquote>
|
||||
<p><strong>WARNING!</strong> You can't customize these messages after starting the bot. Changing these properties while the bot is running will have no effect.</p>
|
||||
</blockquote>
|
||||
|
||||
Reference in new issue
Block a user