Skip to content

Commit

Permalink
Slash commands
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Dec 10, 2023
1 parent 9d15d8f commit d13571a
Show file tree
Hide file tree
Showing 10 changed files with 589 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Writerside/topics/core/Commands.topic
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@

<tr>
<td><code>cache</code></td>
<td><code>MutableStringKeyedMap&lt;Any&gt;</code></td>
<td><code>MutableStringKeyedMap &lt;Any&gt;</code></td>

<td>
The cache object used for this execution, which may contain data set by the current command's
Expand Down
18 changes: 9 additions & 9 deletions Writerside/topics/core/Events.topic
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<li>
<code>body</code> - the function receiver which binds <code>this</code> tho
<code>EventHandler&lt;T&gt;</code>.
<code>EventHandler &lt;T&gt;</code>.
</li>
</list>

Expand All @@ -61,7 +61,7 @@

<td>
<a anchor="event-context">
<code>EventContext&lt;T&gt;</code>
<code>EventContext &lt;T&gt;</code>
</a>
</td>

Expand All @@ -76,7 +76,7 @@

<td>
<a href="Checks.topic">
<code>CheckContext&lt;T&gt;</code>
<code>CheckContext &lt;T&gt;</code>
</a>
</td>

Expand Down Expand Up @@ -247,7 +247,7 @@

<td>
<a href="Checks.topic">
<code>MutableStringKeyedMap&lt;Any&gt;</code>
<code>MutableStringKeyedMap &lt;Any&gt;</code>
</a>
</td>

Expand All @@ -259,7 +259,7 @@

<tr>
<td><code>eventHandler</code></td>
<td><code>EventHandler&lt;T&gt;</code></td>
<td><code>EventHandler &lt;T&gt;</code></td>

<td>
The current event handler object.
Expand Down Expand Up @@ -311,7 +311,7 @@
<chapter title="Custom Context" id="custom-context">
<p>
Kord Extensions sets the <code>customContext</code> property for all events (Kord or otherwise) to an empty
<code>MutableStringKeyedMap&lt;Any&gt;</code>.
<code>MutableStringKeyedMap &lt;Any&gt;</code>.
This allows you to store extra data on your events as part of processing.
</p>

Expand All @@ -333,7 +333,7 @@

<tr>
<td><code>E.extraData</code></td>
<td><code>MutableStingKeyedMap&lt;Any&gt;</code></td>
<td><code>MutableStingKeyedMap &lt;Any&gt;</code></td>

<td>
Quick access to the properly-cast <code>customContext</code> property.
Expand All @@ -345,9 +345,9 @@

<chapter title="Functions" id="custom-context-functions">
<p>
The following functions are extensions on the <code>StringKeyedMap&lt;*&gt;</code> type.
The following functions are extensions on the <code>StringKeyedMap &lt;*&gt;</code> type.
This will be represented using <code>S</code> below.
Additionally, <code>MutableStringKeyedMap&lt;*&gt;</code> will be represented using <code>M</code>
Additionally, <code>MutableStringKeyedMap &lt;*&gt;</code> will be represented using <code>M</code>
below.
</p>

Expand Down
6 changes: 3 additions & 3 deletions Writerside/topics/core/Exceptions.topic
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

<tr>
<td><code>argument</code></td>
<td><code>Argument&lt;*&gt;?</code></td>
<td><code>Argument &lt;*&gt;?</code></td>

<td>
The <code>Argument</code> object representing the argument that failed to parse.
Expand Down Expand Up @@ -257,7 +257,7 @@

<tr>
<td><code>builder</code></td>
<td><code>ConverterBuilder&lt;*&gt;</code></td>
<td><code>ConverterBuilder &lt;*&gt;</code></td>

<td>
The converter builder that failed to validate.
Expand Down Expand Up @@ -392,7 +392,7 @@

<tr>
<td><code>clazz</code></td>
<td><code>KClass&lt;out Extension&gt;</code></td>
<td><code>KClass &lt;out Extension&gt;</code></td>

<td>
The invalid extension's class.
Expand Down
2 changes: 1 addition & 1 deletion Writerside/topics/core/Extensions.topic
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@

<tr>
<td><code>intents</code></td>
<td><code>MutableSet&lt;Intent&gt;</code></td>
<td><code>MutableSet &lt;Intent&gt;</code></td>
<td><code>{ }</code></td>

<td>
Expand Down
4 changes: 2 additions & 2 deletions Writerside/topics/core/The-Bot.topic
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@

<tr>
<td><code>events</code></td>
<td><code>SharedFlow&lt;Any&gt;</code></td>
<td><code>SharedFlow &lt;Any&gt;</code></td>

<td>
Shared flow which combined the events sent by both Kord and Kord Extensions.
Expand All @@ -258,7 +258,7 @@

<tr>
<td><code>eventPublisher</code></td>
<td><code>MutableSharedFlow&lt;Any&gt;</code></td>
<td><code>MutableSharedFlow &lt;Any&gt;</code></td>

<td>
Mutable shared flow used for event publishing.
Expand Down
31 changes: 28 additions & 3 deletions Writerside/topics/core/commands/Application-Commands.topic
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
title="Application Commands ✏️" id="Application-Commands">
title="Application Commands" id="Application-Commands">

<p>
Application commands are a special type of command that makes use of Discord's interaction system.
Expand Down Expand Up @@ -67,7 +67,7 @@

<tr>
<td><code>check</code></td>
<td><code>CheckWithCache&lt;E&gt;</code></td>
<td><code>CheckWithCache &lt;E&gt;</code></td>

<td>
Register a check that must pass for the command's <code>action</code> to be run, which is
Expand Down Expand Up @@ -121,6 +121,31 @@
<td>Description</td>
</tr>

<tr id="command-properties-required:header:text:center">
<td colspan="3">
Required Properties
</td>
</tr>

<tr>
<td><code>name</code></td>
<td><code>String</code></td>

<td>
<format style="bold">Required:</format> The command's name, which is used to invoke the command
and is displayed on Discord.
Your command's name must follow
<a href="https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-naming">
Discord's naming requirements</a>.
</td>
</tr>

<tr id="command-properties-optional:header:text:center">
<td colspan="3">
Optional Properties
</td>
</tr>

<tr>
<td><code>allowByDefault</code></td>
<td><code>Boolean</code></td>
Expand Down Expand Up @@ -189,7 +214,7 @@

<tr>
<td><code>genericCommand</code></td>
<td><code>ApplicationCommand&lt;*&gt;</code></td>
<td><code>ApplicationCommand &lt;*&gt;</code></td>

<td>
Generic command object, representing the command this context belongs to.
Expand Down
15 changes: 7 additions & 8 deletions Writerside/topics/core/commands/Chat-Commands.topic
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

action {
message.respond(
"User ${arguments.user.mention} has permission to mention everyone."
"Hey, ${arguments.user.mention}! Get pinged!"
)
}
}
Expand All @@ -133,7 +133,7 @@

<tr id="extension-builders-checks:div:bottom">
<td><code>chatCommandCheck</code></td>
<td><code>CheckWithCache&lt;MessageCreateEvent&gt;</code></td>
<td><code>CheckWithCache &lt;MessageCreateEvent&gt;</code></td>

<td>
Register a check that must pass for the <code>action</code>
Expand Down Expand Up @@ -203,14 +203,12 @@

<tr>
<td><code>action</code></td>
<td><code>ChatCommandContext&lt;Arguments&gt;</code></td>
<td><code>ChatCommandContext &lt;Arguments&gt;</code></td>

<td>
<format style="bold">Required:</format>
Register the command's action, which will be run when
the command is invoked.
Provide the constructor for an <code>Arguments</code> subtype as the first argument to this
function if your command takes any arguments.
</td>
</tr>

Expand All @@ -222,7 +220,7 @@

<tr>
<td><code>check</code></td>
<td><code>CheckWithCache&lt;MessageCreateEvent&gt;</code></td>
<td><code>CheckWithCache &lt;MessageCreateEvent&gt;</code></td>

<td>
Register a check that must pass for the command's <code>action</code> to be run.
Expand Down Expand Up @@ -278,7 +276,7 @@

<tr>
<td><code>aliases</code></td>
<td><code>Array&lt;String&gt;</code></td>
<td><code>Array &lt;String&gt;</code></td>

<td>
Array of alternative names that may be used to invoke this command.
Expand Down Expand Up @@ -421,6 +419,7 @@
This builder function mirrors the behavior of the <code>chatCommand</code> builder function
defined at <code>Extension</code> level, which you'd normally use to register standalone
commands.
Subcommands inherit the checks that are defined in their parent commands.
</td>
</tr>

Expand All @@ -432,6 +431,7 @@
This builder function allows you to nest grouped commands as deeply as is required.
It mirrors the behavior of the <code>chatGroupCommand</code> builder function defined at
<code>Extension</code> level.
Subcommands inherit the checks that are defined in their parent commands.
</td>
</tr>
</table>
Expand Down Expand Up @@ -584,7 +584,6 @@
</td>
</tr>


<tr id="context-properties-translation:header:text:center">
<td colspan="3">
Data Properties
Expand Down
2 changes: 1 addition & 1 deletion Writerside/topics/core/commands/Converters.topic
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
title="Converters " id="Converters">
title="Converters ✏️" id="Converters">

<p>Start typing here...</p>
</topic>
103 changes: 102 additions & 1 deletion Writerside/topics/core/commands/application/Context-Commands.topic
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,112 @@
</p>

<p>
When registered by a bot, context commands are visible in a menu named <format style="bold">Apps</format>.
When registered by your bot, context commands are visible in a menu named <format style="bold">Apps</format>.
There are two types of context command — message commands and user commands.
They have identical APIs, aside from the target data supplied to them by Discord.
</p>

<chapter title="Extension API" id="extension-api">
The following APIs are available on the <code>Extension</code> type, which you can use to define your
context commands and modify their behavior.

<chapter title="Builders" id="extension-api-builders">
<table style="header-row">
<tr>
<td>Name</td>
<td>Receiver</td>
<td>Description</td>
</tr>

<tr id="extension-api-builders-checks:header:text:center">
<td colspan="3">
Checks
</td>
</tr>

<tr>
<td><code>messageCommandCheck</code></td>
<td><code>CheckWithCache &lt;MessageCommandInteractionCreateEvent&gt;</code></td>

<td>
Register a check that must pass for the <code>action</code>
belonging to all message commands defined within this extension to be run.
For more information on checks, see <a href="Checks.topic">the dedicated documentation</a>.
</td>
</tr>

<tr>
<td><code>userCommandCheck</code></td>
<td><code>CheckWithCache &lt;UserCommandInteractionCreateEvent&gt;</code></td>

<td>
Register a check that must pass for the <code>action</code>
belonging to all user commands defined within this extension to be run.
For more information on checks, see <a href="Checks.topic">the dedicated documentation</a>.
</td>
</tr>

<tr id="extension-api-builders-commands:header:text:center">
<td colspan="3">
Commands
</td>
</tr>

<tr>
<td><code>ephemeralMessageCommand</code></td>
<td><code>EphemeralMessageCommand</code></td>

<td>
Register an <a anchor="message-commands">ephemeral message command</a>.

This builder function optionally takes the constructor of a
<a href="Commands.topic" anchor="modal-forms">modal form class</a> as the first argument,
representing the modal form to display and await input for when the command is executed.
</td>
</tr>

<tr>
<td><code>ephemeralUserCommand</code></td>
<td><code>EphemeralUserCommand</code></td>

<td>
Register an <a anchor="message-commands">ephemeral user command</a>.

This builder function optionally takes the constructor of a
<a href="Commands.topic" anchor="modal-forms">modal form class</a> as the first argument,
representing the modal form to display and await input for when the command is executed.
</td>
</tr>

<tr>
<td><code>publicMessageCommand</code></td>
<td><code>PublicMessageCommand</code></td>

<td>
Register a <a anchor="message-commands">public message command</a>.

This builder function optionally takes the constructor of a
<a href="Commands.topic" anchor="modal-forms">modal form class</a> as the first argument,
representing the modal form to display and await input for when the command is executed.
</td>
</tr>

<tr>
<td><code>publicUserCommand</code></td>
<td><code>PublicUserCommand</code></td>

<td>
Register a <a anchor="message-commands">public user command</a>.

This builder function optionally takes the constructor of a
<a href="Commands.topic" anchor="modal-forms">modal form class</a> as the first argument,s
representing the modal form to display and await input for when the command is executed.
</td>
</tr>
</table>
</chapter>
</chapter>

<chapter title="Message Commands" id="message-commands">
<p>
Message commands are registered by calling the relevant functions in
Expand Down
Loading

0 comments on commit d13571a

Please sign in to comment.