cordo 2.16.0 → 2.16.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
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
|
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: {
|
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)
|