cordo 2.14.0 → 2.15.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cordo",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "A framework for handling complex discord api interactions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"tsconfig.json"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
+
"docs:dev": "vitepress dev docs",
|
|
21
|
+
"docs:build": "vitepress build docs",
|
|
22
|
+
"docs:preview": "vitepress preview docs",
|
|
20
23
|
"build": "tsc",
|
|
21
24
|
"lint": "eslint --ext .ts --ignore-path .gitignore src/**/*.ts",
|
|
22
25
|
"tunnel": "cloudflared tunnel --config ~/.cloudflared/config.yml run fsb",
|
|
@@ -54,6 +57,8 @@
|
|
|
54
57
|
"express": "^4.17.3",
|
|
55
58
|
"hono": "^4.7.7",
|
|
56
59
|
"reflect-metadata": "^0.1.13",
|
|
57
|
-
"typescript": "^5.7.3"
|
|
60
|
+
"typescript": "^5.7.3",
|
|
61
|
+
"vitepress": "^1.6.4",
|
|
62
|
+
"vue": "^3.5.41"
|
|
58
63
|
}
|
|
59
64
|
}
|
package/src/core/gateway.ts
CHANGED
|
@@ -77,11 +77,8 @@ export namespace CordoGateway {
|
|
|
77
77
|
|
|
78
78
|
// if not specifically set, check if it's triggered by a command and if so -> is that command private?
|
|
79
79
|
if (opts?.ephemeral === undefined) {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
opts.ephemeral = isPrivate
|
|
83
|
-
else if (typeof isPrivate === 'function')
|
|
84
|
-
opts.ephemeral = isPrivate(i)
|
|
80
|
+
const commandPrivate = InteractionInternals.get(i).commandEntrypoint?.private
|
|
81
|
+
opts.ephemeral = typeof commandPrivate === 'function' ? commandPrivate(i) : Boolean(commandPrivate)
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
const internals = InteractionInternals.get(i)
|
|
@@ -101,6 +98,8 @@ export namespace CordoGateway {
|
|
|
101
98
|
}
|
|
102
99
|
|
|
103
100
|
if (!internals.answered) {
|
|
101
|
+
internals.answered = true
|
|
102
|
+
|
|
104
103
|
if (payload)
|
|
105
104
|
return apiRequest('post', `/interactions/${i.id}/${i.token}/callback`, payload)
|
|
106
105
|
|
|
@@ -173,8 +172,8 @@ export namespace CordoGateway {
|
|
|
173
172
|
const { route, path } = RoutingResolve.getRouteForCommand(name, 'slash')
|
|
174
173
|
|
|
175
174
|
CordoMagic.setCwd(path)
|
|
176
|
-
if (CordoMagic.getLockfile()?.$runtime.registeredCommands.has(route.
|
|
177
|
-
InteractionInternals.get(i).commandEntrypoint = CordoMagic.getLockfile()!.$runtime.registeredCommands.get(route.
|
|
175
|
+
if (route.routeFilePath && CordoMagic.getLockfile()?.$runtime.registeredCommands.has(route.routeFilePath))
|
|
176
|
+
InteractionInternals.get(i).commandEntrypoint = CordoMagic.getLockfile()!.$runtime.registeredCommands.get(route.routeFilePath)!
|
|
178
177
|
|
|
179
178
|
return RoutingRespond.callRoute(route.routeId, route.args, i)
|
|
180
179
|
}
|
|
@@ -187,8 +186,8 @@ export namespace CordoGateway {
|
|
|
187
186
|
)
|
|
188
187
|
|
|
189
188
|
CordoMagic.setCwd(path)
|
|
190
|
-
if (CordoMagic.getLockfile()?.$runtime.registeredCommands.has(route.
|
|
191
|
-
InteractionInternals.get(i).commandEntrypoint = CordoMagic.getLockfile()!.$runtime.registeredCommands.get(route.
|
|
189
|
+
if (route.routeFilePath && CordoMagic.getLockfile()?.$runtime.registeredCommands.has(route.routeFilePath))
|
|
190
|
+
InteractionInternals.get(i).commandEntrypoint = CordoMagic.getLockfile()!.$runtime.registeredCommands.get(route.routeFilePath)!
|
|
192
191
|
|
|
193
192
|
return RoutingRespond.callRoute(route.routeId, route.args, i)
|
|
194
193
|
}
|
|
@@ -44,13 +44,19 @@ export namespace RoutingFilesystem {
|
|
|
44
44
|
boundary: child.boundary
|
|
45
45
|
})
|
|
46
46
|
}
|
|
47
|
+
for (const child of subTree.commands) {
|
|
48
|
+
out.commands.push({
|
|
49
|
+
path: [ item.name, ...child.path ],
|
|
50
|
+
command: child.command
|
|
51
|
+
})
|
|
52
|
+
}
|
|
47
53
|
} else if (item.isFile()) {
|
|
48
54
|
if (!supportedExtensions.some(ext => item.name.endsWith(`.${ext}`)))
|
|
49
55
|
continue
|
|
50
56
|
|
|
51
57
|
const command = await CommandInternals.readCommand(join(treeRoot, item.name))
|
|
52
58
|
if (command) {
|
|
53
|
-
if (!treeRoot.
|
|
59
|
+
if (!treeRoot.includes(config.defaults.commandRoutePrefix ?? 'command'))
|
|
54
60
|
console.warn(`File ${join(treeRoot, item.name)} defined a command but is not in the command route prefix folder (${config.defaults.commandRoutePrefix ?? 'command'}). The command will probably not trigger the configured route when run.`)
|
|
55
61
|
|
|
56
62
|
out.commands.push({
|
|
@@ -132,15 +138,10 @@ export namespace RoutingFilesystem {
|
|
|
132
138
|
})
|
|
133
139
|
}
|
|
134
140
|
|
|
135
|
-
const commandRoutePrefix = config?.defaults.commandRoutePrefix ?? 'command'
|
|
136
141
|
for (const file of files.commands) {
|
|
137
|
-
const filePath = file.path.join('/')
|
|
138
|
-
? file.path.join('/').slice(commandRoutePrefix.length + 1)
|
|
139
|
-
: file.path.join('/')
|
|
140
|
-
|
|
142
|
+
const filePath = file.path.join('/')
|
|
141
143
|
lockfile.$runtime.registeredCommands.set(filePath, file.command)
|
|
142
144
|
}
|
|
143
|
-
|
|
144
145
|
|
|
145
146
|
return out
|
|
146
147
|
}
|
|
@@ -34,6 +34,11 @@ export namespace RoutingRespond {
|
|
|
34
34
|
if (opts.disableComponents)
|
|
35
35
|
response.push(disableAllComponents())
|
|
36
36
|
|
|
37
|
+
if (opts.isPrivate === undefined) {
|
|
38
|
+
const commandPrivate = InteractionInternals.get(i).commandEntrypoint?.private
|
|
39
|
+
opts.isPrivate = typeof commandPrivate === 'function' ? commandPrivate(i) : Boolean(commandPrivate)
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
let type: InteractionResponseType = InteractionResponseType.Pong
|
|
38
43
|
if (i.type === InteractionType.ApplicationCommand) {
|
|
39
44
|
type = (InteractionInternals.get(i).answered && !opts.asReply)
|