cordo 2.16.0 → 2.16.3
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
CHANGED
|
@@ -196,7 +196,7 @@ export namespace CommandInternals {
|
|
|
196
196
|
let cleanRoute = route
|
|
197
197
|
if (cleanRoute.startsWith(prefix))
|
|
198
198
|
cleanRoute = cleanRoute.slice(prefix.length)
|
|
199
|
-
cleanRoute = cleanRoute.replace(
|
|
199
|
+
cleanRoute = cleanRoute.replace(/\.\w+$/, '')
|
|
200
200
|
|
|
201
201
|
const parts = cleanRoute.split('/')
|
|
202
202
|
let currentLevel = rootCommands
|
|
@@ -250,12 +250,15 @@ export namespace CommandInternals {
|
|
|
250
250
|
const apiCmd: any = {
|
|
251
251
|
name,
|
|
252
252
|
name_localizations: nameLocalizations,
|
|
253
|
-
description,
|
|
254
|
-
description_localizations: descriptionLocalizations,
|
|
255
253
|
type: cmdType,
|
|
256
254
|
options: apiOptions.length > 0 ? apiOptions : undefined
|
|
257
255
|
}
|
|
258
256
|
|
|
257
|
+
if (cmdType === ApplicationCommandType.ChatInput) {
|
|
258
|
+
apiCmd.description = description
|
|
259
|
+
apiCmd.description_localizations = descriptionLocalizations
|
|
260
|
+
}
|
|
261
|
+
|
|
259
262
|
if (tree.command) {
|
|
260
263
|
apiCmd.default_member_permissions = tree.command.defaultMemberPermissions?.toString()
|
|
261
264
|
apiCmd.nsfw = tree.command.nsfw
|
package/src/core/files/config.ts
CHANGED
|
@@ -38,8 +38,12 @@ export type CordoConfig = {
|
|
|
38
38
|
}
|
|
39
39
|
/** The Discord client you are operating as */
|
|
40
40
|
client: {
|
|
41
|
+
/** The ID of the app */
|
|
41
42
|
id: string
|
|
43
|
+
/** The app's public key. Only required if you are receiving interactions via HTTP */
|
|
42
44
|
publicKey: string
|
|
45
|
+
/** The bot token. Only required for actions that call Discord proactively like syncing commands, not required for handling interactions. */
|
|
46
|
+
token: string
|
|
43
47
|
}
|
|
44
48
|
/** Upstream describes the Discord API */
|
|
45
49
|
upstream: {
|
|
@@ -120,7 +124,8 @@ export namespace ConfigInternals {
|
|
|
120
124
|
},
|
|
121
125
|
client: {
|
|
122
126
|
id: '',
|
|
123
|
-
publicKey: ''
|
|
127
|
+
publicKey: '',
|
|
128
|
+
token: ''
|
|
124
129
|
},
|
|
125
130
|
hooks: {
|
|
126
131
|
onRawInteraction: null,
|
package/src/core/gateway.ts
CHANGED
|
@@ -64,6 +64,7 @@ export namespace CordoGateway {
|
|
|
64
64
|
method,
|
|
65
65
|
url,
|
|
66
66
|
baseURL: config.upstream.baseUrl,
|
|
67
|
+
headers: config.client.token ? { Authorization: `Bot ${config.client.token}` } : undefined,
|
|
67
68
|
data: body,
|
|
68
69
|
validateStatus: null
|
|
69
70
|
})
|
|
@@ -337,6 +338,8 @@ export namespace CordoGateway {
|
|
|
337
338
|
const config = CordoMagic.getConfig()
|
|
338
339
|
if (!config?.client.id)
|
|
339
340
|
throw new MissingContextError('Could not upsert command, no client id found in config context.')
|
|
341
|
+
if (!config?.client.token)
|
|
342
|
+
throw new MissingContextError('Could not upsert command, no bot token found in config context (client.token).')
|
|
340
343
|
|
|
341
344
|
const endpoint = guild ? `/applications/${config.client.id}/guilds/${guild}/commands` : `/applications/${config.client.id}/commands`
|
|
342
345
|
return apiRequest('post', endpoint, command)
|