cordo 2.6.2 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/routing/respond.ts +14 -2
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationCommandType, InteractionContextType, InteractionResponseType, InteractionType, MessageFlags, type APIUser } from "discord-api-types/v10"
|
|
1
|
+
import { ApplicationCommandOptionType, ApplicationCommandType, InteractionContextType, InteractionResponseType, InteractionType, MessageFlags, type APIUser } from "discord-api-types/v10"
|
|
2
2
|
import { disableAllComponents } from "../../components"
|
|
3
3
|
import { ComponentType, renderComponent, renderComponentList, type CordoComponent } from "../../components/component"
|
|
4
4
|
import type { RouteInternals, RouteRequest, RouteResponse } from "../files/route"
|
|
@@ -86,6 +86,18 @@ export namespace RoutingRespond {
|
|
|
86
86
|
return out
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
function parseCommandOptions(options: any) {
|
|
90
|
+
if (!options)
|
|
91
|
+
return {}
|
|
92
|
+
|
|
93
|
+
if (options.length === 1) {
|
|
94
|
+
if (options[0].type === ApplicationCommandOptionType.Subcommand || options[0].type === ApplicationCommandOptionType.SubcommandGroup)
|
|
95
|
+
return parseCommandOptions(options[0].options)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return (options as Record<string, any>[]).reduce((out, opt) => ({ [opt.name]: opt.value, ...out }), {})
|
|
99
|
+
}
|
|
100
|
+
|
|
89
101
|
export function buildRouteRequest(
|
|
90
102
|
route: RouteInternals.ParsedRoute,
|
|
91
103
|
args: string[],
|
|
@@ -194,7 +206,7 @@ export namespace RoutingRespond {
|
|
|
194
206
|
// @ts-ignore
|
|
195
207
|
id: interaction.data.id,
|
|
196
208
|
// @ts-ignore
|
|
197
|
-
options: interaction.data.options
|
|
209
|
+
options: parseCommandOptions(interaction.data.options),
|
|
198
210
|
// @ts-ignore
|
|
199
211
|
type: (interaction.data.type === ApplicationCommandType.ChatInput)
|
|
200
212
|
? 'chat'
|