@went.tf/discord-bot-framework 2.0.0 → 2.1.0
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/README.md +22 -3
- package/build/.tsbuildinfo +1 -1
- package/build/commands/build-application-commands-body.d.ts +6 -0
- package/build/commands/build-application-commands-body.d.ts.map +1 -1
- package/build/commands/build-application-commands-body.js +34 -1
- package/build/commands/build-application-commands-body.js.map +1 -1
- package/build/commands/schema/application-command-leaf-option.schema.d.ts +9 -9
- package/build/commands/schema/application-command-leaf-option.schema.js +9 -9
- package/build/commands/schema/application-command-leaf-option.schema.js.map +1 -1
- package/build/commands/schema/application-command-leaf-option.schema.json +36 -9
- package/build/commands/schema/application-command-subcommand-group.schema.d.ts +1 -1
- package/build/commands/schema/application-command-subcommand-group.schema.js +1 -1
- package/build/commands/schema/application-command-subcommand-group.schema.js.map +1 -1
- package/build/commands/schema/application-command-subcommand-group.schema.json +4 -1
- package/build/commands/schema/application-command-subcommand.schema.d.ts +1 -1
- package/build/commands/schema/application-command-subcommand.schema.js +1 -1
- package/build/commands/schema/application-command-subcommand.schema.js.map +1 -1
- package/build/commands/schema/application-command-subcommand.schema.json +4 -1
- package/build/commands/schema/application-command-type.schema.d.ts +2 -2
- package/build/commands/schema/application-command-type.schema.d.ts.map +1 -1
- package/build/commands/schema/application-command-type.schema.js +2 -2
- package/build/commands/schema/application-command-type.schema.js.map +1 -1
- package/build/commands/schema/application-command-type.schema.json +5 -2
- package/build/commands/schema/application-integration-type.schema.d.ts +2 -2
- package/build/commands/schema/application-integration-type.schema.d.ts.map +1 -1
- package/build/commands/schema/application-integration-type.schema.js +2 -2
- package/build/commands/schema/application-integration-type.schema.js.map +1 -1
- package/build/commands/schema/application-integration-type.schema.json +4 -2
- package/build/commands/schema/channel-type.schema.d.ts +2 -2
- package/build/commands/schema/channel-type.schema.d.ts.map +1 -1
- package/build/commands/schema/channel-type.schema.js +6 -2
- package/build/commands/schema/channel-type.schema.js.map +1 -1
- package/build/commands/schema/channel-type.schema.json +12 -2
- package/build/commands/schema/chat-input-command.schema.d.ts +1 -1
- package/build/commands/schema/chat-input-command.schema.js +1 -1
- package/build/commands/schema/chat-input-command.schema.js.map +1 -1
- package/build/commands/schema/chat-input-command.schema.json +4 -1
- package/build/commands/schema/context-menu-command.schema.d.ts +1 -1
- package/build/commands/schema/context-menu-command.schema.js +1 -1
- package/build/commands/schema/context-menu-command.schema.js.map +1 -1
- package/build/commands/schema/context-menu-command.schema.json +3 -1
- package/build/commands/schema/enum-maps.d.ts +52 -0
- package/build/commands/schema/enum-maps.d.ts.map +1 -0
- package/build/commands/schema/enum-maps.js +54 -0
- package/build/commands/schema/enum-maps.js.map +1 -0
- package/build/commands/schema/index.d.ts +1 -0
- package/build/commands/schema/index.d.ts.map +1 -1
- package/build/commands/schema/index.js +1 -0
- package/build/commands/schema/index.js.map +1 -1
- package/build/commands/schema/interaction-context-type.schema.d.ts +2 -2
- package/build/commands/schema/interaction-context-type.schema.d.ts.map +1 -1
- package/build/commands/schema/interaction-context-type.schema.js +2 -2
- package/build/commands/schema/interaction-context-type.schema.js.map +1 -1
- package/build/commands/schema/interaction-context-type.schema.json +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,18 +163,28 @@ autocomplete?, modal? }`) no longer describe their own wire shape at all.
|
|
|
163
163
|
|
|
164
164
|
```json
|
|
165
165
|
[
|
|
166
|
-
{ "type":
|
|
166
|
+
{ "type": "CHAT_INPUT", "name": "ping", "description": "Replies with pong" },
|
|
167
167
|
{
|
|
168
|
-
"type":
|
|
168
|
+
"type": "CHAT_INPUT",
|
|
169
169
|
"name": "search",
|
|
170
170
|
"description": "Search for something",
|
|
171
171
|
"options": [
|
|
172
|
-
{ "type":
|
|
172
|
+
{ "type": "STRING", "name": "query", "description": "Query string", "required": true }
|
|
173
173
|
]
|
|
174
174
|
}
|
|
175
175
|
]
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
+
`type` (and `contexts`/`integration_types`/`channel_types`) accept either
|
|
179
|
+
Discord's raw numeric value or the UPPER_SNAKE_CASE string alias shown
|
|
180
|
+
above — nobody should have to remember that `3` means `STRING`. Both
|
|
181
|
+
forms, and any mix of the two, are always valid; `buildApplicationCommandsBody`
|
|
182
|
+
resolves whichever form was used to its real numeric value right before
|
|
183
|
+
writing each command/option into the final REST body, using the mapping
|
|
184
|
+
in `./commands/schema`'s `enum-maps.ts` (sourced from `discord-api-types`'
|
|
185
|
+
own enums, not hand-duplicated numbers, so it can't drift). The numeric
|
|
186
|
+
form still works and always will — this is additive, not a replacement.
|
|
187
|
+
|
|
178
188
|
2. Parse and validate it before doing anything else with it:
|
|
179
189
|
|
|
180
190
|
```ts
|
|
@@ -265,6 +275,15 @@ building blocks), `application-command-option-choice`,
|
|
|
265
275
|
`application-command-type`, `interaction-context-type`,
|
|
266
276
|
`application-integration-type`, `channel-type`.
|
|
267
277
|
|
|
278
|
+
`./commands/schema` also exports `enum-maps.ts`'s `APPLICATION_COMMAND_TYPE_MAP`,
|
|
279
|
+
`APPLICATION_COMMAND_OPTION_TYPE_MAP`, `INTERACTION_CONTEXT_TYPE_MAP`,
|
|
280
|
+
`APPLICATION_INTEGRATION_TYPE_MAP`, `CHANNEL_TYPE_MAP`, and `resolveEnumValue` —
|
|
281
|
+
the same lookup tables `buildApplicationCommandsBody` uses internally to
|
|
282
|
+
resolve `commands.json`'s UPPER_SNAKE_CASE string aliases, exported in case
|
|
283
|
+
other tooling built on top of this package needs the same mapping (e.g. a
|
|
284
|
+
linter or a codemod converting old numeric `commands.json` files to the
|
|
285
|
+
string form).
|
|
286
|
+
|
|
268
287
|
Base fragments use `additionalProperties: false` for strictness — if your
|
|
269
288
|
bot needs a genuinely new top-level field per command entry, you'll need
|
|
270
289
|
`unevaluatedProperties`-based composition instead of `allOf`, since
|