cordo 1.17.3 → 2.0.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.
Files changed (93) hide show
  1. package/package.json +22 -4
  2. package/src/components/index.ts +41 -0
  3. package/src/core/index.ts +77 -0
  4. package/src/errors/index.ts +6 -0
  5. package/src/functions/index.ts +5 -0
  6. package/src/http/index.ts +2 -0
  7. package/src/index.ts +0 -217
  8. package/.eslintrc.js +0 -11
  9. package/dist/api.d.ts +0 -27
  10. package/dist/api.js +0 -209
  11. package/dist/api.js.map +0 -1
  12. package/dist/index.d.ts +0 -50
  13. package/dist/index.js +0 -184
  14. package/dist/index.js.map +0 -1
  15. package/dist/lib/default-logger.d.ts +0 -7
  16. package/dist/lib/default-logger.js +0 -8
  17. package/dist/lib/default-logger.js.map +0 -1
  18. package/dist/lib/permission-checks.d.ts +0 -5
  19. package/dist/lib/permission-checks.js +0 -46
  20. package/dist/lib/permission-checks.js.map +0 -1
  21. package/dist/lib/permission-strings.d.ts +0 -48
  22. package/dist/lib/permission-strings.js +0 -64
  23. package/dist/lib/permission-strings.js.map +0 -1
  24. package/dist/lib/user-error-messages.d.ts +0 -7
  25. package/dist/lib/user-error-messages.js +0 -36
  26. package/dist/lib/user-error-messages.js.map +0 -1
  27. package/dist/lib/utils.d.ts +0 -2
  28. package/dist/lib/utils.js +0 -16
  29. package/dist/lib/utils.js.map +0 -1
  30. package/dist/manager/autocompleter.d.ts +0 -8
  31. package/dist/manager/autocompleter.js +0 -58
  32. package/dist/manager/autocompleter.js.map +0 -1
  33. package/dist/manager/commands.d.ts +0 -11
  34. package/dist/manager/commands.js +0 -102
  35. package/dist/manager/commands.js.map +0 -1
  36. package/dist/manager/components.d.ts +0 -11
  37. package/dist/manager/components.js +0 -109
  38. package/dist/manager/components.js.map +0 -1
  39. package/dist/manager/states.d.ts +0 -12
  40. package/dist/manager/states.js +0 -56
  41. package/dist/manager/states.js.map +0 -1
  42. package/dist/replies.d.ts +0 -18
  43. package/dist/replies.js +0 -236
  44. package/dist/replies.js.map +0 -1
  45. package/dist/types/base.d.ts +0 -327
  46. package/dist/types/base.js +0 -4
  47. package/dist/types/base.js.map +0 -1
  48. package/dist/types/component.d.ts +0 -69
  49. package/dist/types/component.js +0 -3
  50. package/dist/types/component.js.map +0 -1
  51. package/dist/types/const.d.ts +0 -90
  52. package/dist/types/const.js +0 -102
  53. package/dist/types/const.js.map +0 -1
  54. package/dist/types/custom.d.ts +0 -81
  55. package/dist/types/custom.js +0 -3
  56. package/dist/types/custom.js.map +0 -1
  57. package/dist/types/middleware.d.ts +0 -42
  58. package/dist/types/middleware.js +0 -2
  59. package/dist/types/middleware.js.map +0 -1
  60. package/src/api.ts +0 -221
  61. package/src/lib/default-logger.ts +0 -11
  62. package/src/lib/permission-checks.ts +0 -76
  63. package/src/lib/permission-strings.ts +0 -72
  64. package/src/lib/user-error-messages.ts +0 -43
  65. package/src/lib/utils.ts +0 -21
  66. package/src/manager/autocompleter.ts +0 -69
  67. package/src/manager/commands.ts +0 -119
  68. package/src/manager/components.ts +0 -133
  69. package/src/manager/states.ts +0 -65
  70. package/src/replies.ts +0 -267
  71. package/src/types/base.ts +0 -395
  72. package/src/types/component.ts +0 -90
  73. package/src/types/const.ts +0 -102
  74. package/src/types/custom.ts +0 -116
  75. package/src/types/middleware.ts +0 -46
  76. package/tsconfig.json +0 -29
  77. package/v2/_test/command.ts +0 -47
  78. package/v2/_test/general-test.ts +0 -34
  79. package/v2/api.ts +0 -193
  80. package/v2/components/$component.ts +0 -23
  81. package/v2/components/button-component.ts +0 -152
  82. package/v2/components/select-component.ts +0 -140
  83. package/v2/index.ts +0 -194
  84. package/v2/interactions/$interaction.ts +0 -104
  85. package/v2/interactions/$shared-types.ts +0 -88
  86. package/v2/interactions/autocomplete-interaction.ts +0 -24
  87. package/v2/interactions/command-interaction.ts +0 -94
  88. package/v2/interactions/component-interaction.ts +0 -51
  89. package/v2/interactions/modal-submit-interaction.ts +0 -41
  90. package/v2/types/const.ts +0 -137
  91. package/v2/types/discord.ts +0 -160
  92. package/v2/types/helper.ts +0 -16
  93. package/v2/types/middleware.ts +0 -12
package/package.json CHANGED
@@ -1,12 +1,27 @@
1
1
  {
2
2
  "name": "cordo",
3
- "version": "1.17.3",
3
+ "version": "2.0.0",
4
4
  "description": "A framework for handling complex discord api interactions",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "exports": {
6
+ ".": "./src/index.ts",
7
+ "./core": "./src/core/index.ts",
8
+ "./components": "./src/components/index.ts",
9
+ "./errors": "./src/errors/index.ts",
10
+ "./functions": "./src/functions/index.ts",
11
+ "./http": "./src/http/index.ts"
12
+ },
13
+ "files": [
14
+ "src/index.ts",
15
+ "src/core/index.ts",
16
+ "src/components/index.ts",
17
+ "src/errors/index.ts",
18
+ "src/functions/index.ts",
19
+ "src/http/index.ts"
20
+ ],
7
21
  "scripts": {
8
22
  "build": "tsc",
9
23
  "lint": "eslint --ext .ts --ignore-path .gitignore src/**/*.ts",
24
+ "tunnel": "cloudflared tunnel --config ~/.cloudflared/config.yml run fsb",
10
25
  "dev": "tsc && node --trace-warnings ./build/index.js",
11
26
  "test": "echo \"Error: no tests specified\" && exit 0",
12
27
  "prepub": "npm run lint && npm run build && npm run test && npm pub"
@@ -23,8 +38,11 @@
23
38
  "homepage": "https://github.com/Maanex/cordo#readme",
24
39
  "dependencies": {
25
40
  "axios": "^0.21.4",
41
+ "defu": "^6.1.4",
42
+ "discord-api-types": "^0.37.119",
26
43
  "discord-interactions": "^2.4.1",
27
- "express": "^4.17.3"
44
+ "express": "^4.17.3",
45
+ "type-fest": "^4.34.1"
28
46
  },
29
47
  "devDependencies": {
30
48
  "@types/axios": "^0.14.0",
@@ -0,0 +1,41 @@
1
+
2
+ import { createModifier as _createModifier } from './modifier'
3
+ import {
4
+ createComponent as _createComponent,
5
+ ComponentType as _ComponentType,
6
+ readComponent as _readComponent,
7
+ isComponent as _isComponent,
8
+ renderComponent as _renderComponent,
9
+ renderComponentList as _renderComponentList,
10
+ } from './component'
11
+
12
+ export { button } from './builtin/button'
13
+ export { container } from './builtin/container'
14
+ export { collection } from './builtin/collection'
15
+ export { divider } from './builtin/divider'
16
+ export { gallery } from './builtin/gallery'
17
+ export { image } from './builtin/image'
18
+ export { linkButton } from './builtin/link-button'
19
+ export { row } from './builtin/row'
20
+ export { section } from './builtin/section'
21
+ export { selectString } from './builtin/select-string'
22
+ export { spacer } from './builtin/spacer'
23
+ export { text } from './builtin/text'
24
+
25
+ export { debugIdToLabel } from './mods/debug-id-to-label'
26
+ export { debugPrint } from './mods/debug-print'
27
+ export { debugRoute } from './mods/debug-route'
28
+ export { disableAllComponents } from './mods/disable-all-components'
29
+
30
+ export type { CordoComponent, StringComponentType } from './component'
31
+
32
+ export namespace Extend {
33
+ export const createModifier = _createModifier
34
+
35
+ export const createComponent = _createComponent
36
+ export const ComponentType = _ComponentType
37
+ export const readComponent = _readComponent
38
+ export const isComponent = _isComponent
39
+ export const renderComponent = _renderComponent
40
+ export const renderComponentList = _renderComponentList
41
+ }
@@ -0,0 +1,77 @@
1
+ import type { APIInteraction } from 'discord-api-types/v10'
2
+ import defu from 'defu'
3
+ import type { PartialDeep } from 'type-fest'
4
+ import { ConfigInternals, type CordoConfig, type ParsedCordoConfig } from './files/config'
5
+ import { LockfileInternals } from './files/lockfile'
6
+ import { CordoGateway } from './gateway'
7
+ import { RoutingFilesystem } from './routing/filesystem'
8
+
9
+ export { type DynamicTypes } from './dynamic-types'
10
+ export { type CordoConfig, defineCordoConfig } from './files/config'
11
+ export { type CordoRoute, type RouteRequest, defineCordoRoute, assertCordoRequest } from './files/route'
12
+ export { type CordoErrorBoundary, defineCordoErrorBoundary } from './files/error-boundary'
13
+ export { type CordoInteraction } from './interaction'
14
+
15
+ //
16
+
17
+ let lockfile: LockfileInternals.ParsedLockfile | null = null
18
+ let config: ParsedCordoConfig | null = null
19
+
20
+ async function mountCordo(configOverrides?: PartialDeep<CordoConfig>) {
21
+ const fileConfig = await ConfigInternals.readAndParseConfig()
22
+ config = configOverrides ? defu(configOverrides, fileConfig) as ParsedCordoConfig : fileConfig
23
+
24
+ lockfile = await LockfileInternals.readOrCreateLockfile(config.lockfile)
25
+ await RoutingFilesystem.readFsTreeAndSyncLockfile(config.paths.routes, lockfile)
26
+
27
+ LockfileInternals.writeLockfile(config.lockfile, lockfile, config.typeDest)
28
+ }
29
+
30
+ function triggerInteraction(interaction: APIInteraction, opts: {
31
+ httpCallback?: (payload: any) => any
32
+ } = {}) {
33
+ if (!lockfile || !config)
34
+ throw new Error('Cordo is not mounted')
35
+
36
+ CordoGateway.triggerInteraction({
37
+ interaction,
38
+ httpCallback: opts.httpCallback,
39
+ lockfile,
40
+ config
41
+ })
42
+ }
43
+
44
+ /**
45
+ * you can provide constants you will commonly use in your routes to cordo
46
+ * cordo will then create a lookup table to more efficiently access these constants in internal routing
47
+ * you should not notice any difference but it will allow you to store more data on click or submit functions
48
+ */
49
+ function registerConstants(constants: readonly string[]) {
50
+ if (!lockfile || !config)
51
+ throw new Error('Cordo is not mounted')
52
+
53
+ let changesMade = false
54
+ for (const entry of constants) {
55
+ if (entry.length <= LockfileInternals.Const.idLength) // too short to save any space
56
+ continue
57
+ if (lockfile!.lut.includes(entry))
58
+ continue
59
+
60
+ lockfile.lut[lockfile.reg.lutCounter++] = entry
61
+ changesMade = true
62
+ }
63
+
64
+ if (changesMade)
65
+ return LockfileInternals.writeLockfile(config!.lockfile, lockfile!, config!.typeDest)
66
+ else
67
+ return Promise.resolve()
68
+ }
69
+
70
+ //
71
+
72
+ export const Cordo = {
73
+ mountCordo,
74
+ registerConstants,
75
+ triggerInteraction
76
+ }
77
+ Object.freeze(Cordo)
@@ -0,0 +1,6 @@
1
+
2
+
3
+ export { CordoError } from './cordo-error'
4
+
5
+ export { RouteNotFoundError } from './builtin/route-not-found'
6
+ export { RouteAssumptionFailedError } from './builtin/route-assumption-failed'
@@ -0,0 +1,5 @@
1
+ export { goto } from './impl/goto'
2
+ export { run } from './impl/run'
3
+ export { value } from './impl/value'
4
+
5
+ export type { CordoFunct, CordoFunctRun } from './funct'
@@ -0,0 +1,2 @@
1
+
2
+ export { useWithExpress } from './express'
package/src/index.ts CHANGED
@@ -1,218 +1 @@
1
- import { verifyKeyMiddleware } from "discord-interactions"
2
- import { Request, Response } from "express"
3
- import { InteractionCallbackType, InteractionType } from './types/const'
4
- import { CordoConfig, CustomLogger, GuildDataMiddleware, InteractionCallbackMiddleware, UserDataMiddleware, ApiResponseHandlerMiddleware, InteractionPreprocessorMiddleware } from './types/middleware'
5
- import { GenericInteraction } from './types/base'
6
- import CordoAPI from './api'
7
- import DefaultLogger from './lib/default-logger'
8
- import CordoCommandsManager from './manager/commands'
9
- import CordoComponentsManager from './manager/components'
10
- import CordoStatesManager from './manager/states'
11
- import { InteractionCommandAutocompleteHandler, InteractionCommandHandler, InteractionComponentHandler, InteractionUIState } from "./types/custom"
12
- import CordoAutocompleterManager from "./manager/autocompleter"
13
1
 
14
-
15
- export * from './api'
16
- export * from './replies'
17
- export * from './lib/default-logger'
18
- export * from './lib/permission-strings'
19
- export * from './types/base'
20
- export * from './types/component'
21
- export * from './types/const'
22
- export * from './types/custom'
23
- export * from './types/middleware'
24
-
25
- export default class Cordo {
26
-
27
- private static __data = {
28
- config: {
29
- botId: null,
30
- texts: {
31
- interaction_not_owned_title: 'Nope!',
32
- interaction_not_owned_description: 'You cannot interact with this widget as you did not create it. Run the command yourself to get a interactable widget.',
33
- interaction_not_permitted_title: 'No permission!',
34
- interaction_not_permitted_description_generic: 'You cannot do this.',
35
- interaction_not_permitted_description_bot_admin: 'Only bot admins can do this.',
36
- interaction_not_permitted_description_guild_admin: 'Only for server admins.',
37
- interaction_not_permitted_description_manage_server: 'Only people with the "Manage Server" permission can do this.',
38
- interaction_not_permitted_description_manage_messages: 'Only people with the "Manage Messages" permission can dothis.',
39
- interaction_failed: 'We are very sorry but an error occured while processing your command. Please try again.',
40
- interaction_invalid_title: 'Error executing this command',
41
- interaction_invalid_description: 'The command was not found. Please contact the developer.'
42
- }
43
- } as CordoConfig,
44
- commandHandlers: CordoCommandsManager.commandHandlers,
45
- componentHandlers: CordoComponentsManager.componentHandlers,
46
- slottedComponentHandlers: CordoComponentsManager.slottedComponentHandlers,
47
- uiStates: CordoStatesManager.uiStates,
48
- slottedUiStates: CordoStatesManager.slottedUiStates,
49
- middlewares: {
50
- interactionCallback: [] as InteractionCallbackMiddleware[],
51
- interactionPreprocessor: [] as InteractionPreprocessorMiddleware<GenericInteraction>[],
52
- fetchGuildData: null as GuildDataMiddleware,
53
- fetchUserData: null as UserDataMiddleware,
54
- apiResponseHandler: null as ApiResponseHandlerMiddleware
55
- },
56
- logger: new DefaultLogger() as CustomLogger
57
- }
58
-
59
- public static get _data() {
60
- return Cordo.__data
61
- }
62
-
63
- //
64
-
65
- public static init(config: CordoConfig) {
66
- if (!config.texts) config.texts = Cordo._data.config.texts
67
- Cordo._data.config = config
68
-
69
- if (config.contextPath)
70
- Cordo.findContext(config.contextPath)
71
- if (config.commandHandlerPath)
72
- CordoCommandsManager.findCommandHandlers(config.commandHandlerPath)
73
- if (config.componentHandlerPath)
74
- CordoComponentsManager.findComponentHandlers(config.componentHandlerPath)
75
- if (config.uiStatesPath)
76
- CordoStatesManager.findUiStates(config.uiStatesPath)
77
- if (config.autocompleterPath)
78
- CordoAutocompleterManager.findAutocompleteHandlers(config.autocompleterPath)
79
- }
80
-
81
- //
82
-
83
- public static findContext(dir: string | string[]) {
84
- if (typeof dir === 'string')
85
- dir = [ dir ]
86
- try {
87
- CordoCommandsManager.findCommandHandlers([ ...dir, 'commands' ])
88
- } catch (ignore) {}
89
- try {
90
- CordoComponentsManager.findComponentHandlers([ ...dir, 'components' ])
91
- } catch (ignore) {}
92
- try {
93
- CordoStatesManager.findUiStates([ ...dir, 'states' ])
94
- } catch (ignore) {}
95
- try {
96
- CordoAutocompleterManager.findAutocompleteHandlers([ ...dir, 'autocompleter' ])
97
- } catch (ignore) {}
98
- }
99
-
100
- public static updateBotId(newId: string) {
101
- Cordo._data.config.botId = newId
102
- }
103
-
104
- //
105
-
106
- public static findCommandHandlers(dir: string | string[], prefix?: string) {
107
- CordoCommandsManager.findCommandHandlers(dir, prefix)
108
- }
109
-
110
- public static registerCommandHandler(command: string, handler: InteractionCommandHandler) {
111
- CordoCommandsManager.registerCommandHandler(command, handler)
112
- }
113
-
114
- public static findComponentHandlers(dir: string | string[], prefix?: string) {
115
- CordoComponentsManager.findComponentHandlers(dir, prefix)
116
- }
117
-
118
- public static registerComponentHandler(id: string, handler: InteractionComponentHandler) {
119
- CordoComponentsManager.registerComponentHandler(id, handler)
120
- }
121
-
122
- public static findUiStates(dir: string | string[], prefix?: string) {
123
- CordoStatesManager.findUiStates(dir, prefix)
124
- }
125
-
126
- public static registerUiState(id: string, state: InteractionUIState) {
127
- CordoStatesManager.registerUiState(id, state)
128
- }
129
-
130
- public static findAutocompleteHandlers(dir: string | string[], prefix?: string) {
131
- CordoAutocompleterManager.findAutocompleteHandlers(dir, prefix)
132
- }
133
-
134
- public static registerAutocompleteHandler(id: string, handler: InteractionCommandAutocompleteHandler) {
135
- CordoAutocompleterManager.registerAutocompleteHandler(id, handler)
136
- }
137
-
138
- //
139
-
140
- public static addMiddlewareInteractionCallback(fun: InteractionCallbackMiddleware) {
141
- Cordo._data.middlewares.interactionCallback.push(fun)
142
- }
143
-
144
- public static addMiddlewareInteractionPreprocessor(fun: InteractionPreprocessorMiddleware<GenericInteraction>) {
145
- Cordo._data.middlewares.interactionPreprocessor.push(fun)
146
- }
147
-
148
- public static setMiddlewareGuildData(fun: GuildDataMiddleware) {
149
- Cordo._data.middlewares.fetchGuildData = fun
150
- }
151
-
152
- public static setMiddlewareUserData(fun: UserDataMiddleware) {
153
- Cordo._data.middlewares.fetchUserData = fun
154
- }
155
-
156
- public static setMiddlewareApiResponseHandler(fun: ApiResponseHandlerMiddleware) {
157
- Cordo._data.middlewares.apiResponseHandler = fun
158
- }
159
-
160
- //
161
-
162
- public static async emitInteraction(i: GenericInteraction) {
163
- i._answered = false
164
-
165
- if (Cordo._data.config.immediateDefer?.(i)) {
166
- if (i.type === InteractionType.COMMAND)
167
- CordoAPI.interactionCallback(i, InteractionCallbackType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE)
168
- else if (i.type === InteractionType.COMPONENT)
169
- CordoAPI.interactionCallback(i, InteractionCallbackType.DEFERRED_UPDATE_MESSAGE)
170
- }
171
-
172
- for (const preprocessor of Cordo._data.middlewares.interactionPreprocessor) {
173
- i = preprocessor(i)
174
- if (i === null)
175
- return // preprocessor already handled this
176
- }
177
-
178
- if (i.guild_id && !!Cordo._data.middlewares.fetchGuildData && typeof Cordo._data.middlewares.fetchGuildData === 'function') {
179
- i.guildData = Cordo._data.middlewares.fetchGuildData(i.guild_id, i)
180
- if (!!(i.guildData as any).then) i.guildData = await (i.guildData as any)
181
- }
182
-
183
- if (!i.user)
184
- i.user = i.member.user
185
-
186
- if (i.user.id && !!Cordo._data.middlewares.fetchUserData && typeof Cordo._data.middlewares.fetchUserData === 'function') {
187
- i.userData = Cordo._data.middlewares.fetchUserData(i.user.id, i)
188
- if (!!(i.userData as any).then) i.userData = await (i.userData as any)
189
- }
190
-
191
- if (i.type === InteractionType.COMMAND)
192
- CordoCommandsManager.onCommand(i)
193
- else if (i.type === InteractionType.COMPONENT)
194
- CordoComponentsManager.onComponent(i)
195
- else if (i.type === InteractionType.COMMAND_AUTOCOMPLETE)
196
- CordoAutocompleterManager.onCommandAutocomplete(i)
197
- else if (i.type === InteractionType.MODAL_SUBMIT) // TODO fix this, temp solution
198
- CordoComponentsManager.onComponent(i as any)
199
- else
200
- Cordo._data.logger.warn(`Unknown interaction type ${(i as any).type}`)
201
- }
202
-
203
- public static useWithExpress(clientPublicKey: string) {
204
- if (!clientPublicKey)
205
- throw new Error('You must specify a Discord client public key');
206
-
207
- const checkKey = verifyKeyMiddleware(clientPublicKey)
208
-
209
- return (req: Request, res: Response) => {
210
- checkKey(req, res, () => {
211
- const interaction = req.body as GenericInteraction
212
- interaction._httpCallback = (payload: any) => res.status(200).json(payload)
213
- Cordo.emitInteraction(interaction)
214
- })
215
- }
216
- }
217
-
218
- }
package/.eslintrc.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parser: '@typescript-eslint/parser',
4
- env: {
5
- node: true
6
- },
7
- plugins: [
8
- '@typescript-eslint'
9
- ],
10
- extends: 'maanex'
11
- }
package/dist/api.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { InteractionApplicationCommandCallbackData, InteractionCallbackFollowup } from './types/custom';
2
- import { GenericInteraction } from './types/base';
3
- import { InteractionCallbackType, InteractionComponentFlag } from './types/const';
4
- import { InteractionApplicationCommandAutocompleteCallbackData, InteractionDefferedCallbackData, InteractionOpenModalData } from './index';
5
- export default class CordoAPI {
6
- static interactionCallback(i: GenericInteraction, type: InteractionCallbackType.PONG): Promise<InteractionCallbackFollowup>;
7
- static interactionCallback(i: GenericInteraction, type: InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE, data: InteractionApplicationCommandCallbackData, contextId?: string, useRaw?: boolean): Promise<InteractionCallbackFollowup>;
8
- static interactionCallback(i: GenericInteraction, type: InteractionCallbackType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE, data?: InteractionDefferedCallbackData): Promise<InteractionCallbackFollowup>;
9
- static interactionCallback(i: GenericInteraction, type: InteractionCallbackType.DEFERRED_UPDATE_MESSAGE, data?: InteractionDefferedCallbackData): Promise<InteractionCallbackFollowup>;
10
- static interactionCallback(i: GenericInteraction, type: InteractionCallbackType.UPDATE_MESSAGE, data: InteractionApplicationCommandCallbackData, contextId?: string, useRaw?: boolean): Promise<InteractionCallbackFollowup>;
11
- static interactionCallback(i: GenericInteraction, type: InteractionCallbackType.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT, data: InteractionApplicationCommandAutocompleteCallbackData, contextId?: string, useRaw?: boolean): Promise<InteractionCallbackFollowup>;
12
- static interactionCallback(i: GenericInteraction, type: InteractionCallbackType.MODAL, data: InteractionOpenModalData, contextId?: string, useRaw?: boolean): Promise<InteractionCallbackFollowup>;
13
- private static handleCallbackResponse;
14
- /**
15
- * Transforms the shorthand way of writing into proper discord api compatible objects
16
- */
17
- static normaliseData(data: InteractionApplicationCommandCallbackData, i?: GenericInteraction, contextId?: string, type?: InteractionCallbackType): void;
18
- private static normalizeFindAndResolveSmartEmbed;
19
- private static normalizeApplyFlags;
20
- static compileCustomId(customId: string, flags?: InteractionComponentFlag[], contextId?: string): string;
21
- static parseCustomId(rawId: string): {
22
- contextId: any;
23
- _reserved: any;
24
- customId: any;
25
- flagsRaw: any;
26
- };
27
- }
package/dist/api.js DELETED
@@ -1,209 +0,0 @@
1
- import axios from 'axios';
2
- import PermissionStrings from './lib/permission-strings';
3
- import { InteractionResponseFlags } from './types/const';
4
- import { ComponentType, InteractionCallbackType, InteractionComponentFlag } from './types/const';
5
- import PermissionChecks from './lib/permission-checks';
6
- import Cordo from './index';
7
- export default class CordoAPI {
8
- static async interactionCallback(i, type, data, contextId, useRaw) {
9
- if (!useRaw)
10
- CordoAPI.normaliseData(data, i, contextId, type);
11
- if (data?.components)
12
- i._answerComponents = data.components;
13
- if (!i._answered) {
14
- i._answered = true;
15
- if (!!i._httpCallback) {
16
- i._httpCallback({ type, data });
17
- }
18
- else {
19
- const res = await axios.post(`https://discord.com/api/v9/interactions/${i.id}/${i.token}/callback`, { type, data }, { validateStatus: null });
20
- CordoAPI.handleCallbackResponse(res, type, data);
21
- }
22
- }
23
- else {
24
- switch (type) {
25
- case InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE: {
26
- const res = await axios.post(`https://discord.com/api/v9/webhooks/${Cordo._data.config.botId}/${i.token}`, data, { validateStatus: null });
27
- CordoAPI.handleCallbackResponse(res, type, data);
28
- break;
29
- }
30
- case InteractionCallbackType.UPDATE_MESSAGE: {
31
- const res = await axios.patch(`https://discord.com/api/v9/webhooks/${Cordo._data.config.botId}/${i.token}/messages/@original`, data, { validateStatus: null });
32
- CordoAPI.handleCallbackResponse(res, type, data);
33
- break;
34
- }
35
- }
36
- }
37
- return {
38
- async getMessage() {
39
- const res = await axios.get(`https://discord.com/api/v8/webhooks/${Cordo._data.config.botId}/${i.token}/messages/@original`, { validateStatus: null });
40
- if (res.status !== 200)
41
- return null;
42
- return res.data;
43
- },
44
- edit(editData, editUseRaw = useRaw) {
45
- CordoAPI.interactionCallback(i, InteractionCallbackType.UPDATE_MESSAGE, editData, contextId, editUseRaw);
46
- }
47
- };
48
- }
49
- static handleCallbackResponse(res, type, data) {
50
- if (Cordo._data.middlewares.apiResponseHandler) {
51
- Cordo._data.middlewares.apiResponseHandler(res);
52
- }
53
- else if (res.status >= 300) {
54
- Cordo._data.logger.warn('Interaction callback failed with error:');
55
- Cordo._data.logger.warn(JSON.stringify(res.data, null, 2));
56
- Cordo._data.logger.warn('Request payload:');
57
- Cordo._data.logger.warn(JSON.stringify({ type, data }, null, 2));
58
- }
59
- }
60
- /**
61
- * Transforms the shorthand way of writing into proper discord api compatible objects
62
- */
63
- static normaliseData(data, i, contextId, type) {
64
- if (!data)
65
- return;
66
- // explicitly not using this. in this function due to unwanted side-effects in lambda functions
67
- if (i)
68
- Cordo._data.middlewares.interactionCallback.forEach(f => f(data, i));
69
- CordoAPI.normalizeFindAndResolveSmartEmbed(data, type);
70
- const isEmphemeral = (data.flags & InteractionResponseFlags.EPHEMERAL) !== 0;
71
- if (data.components?.length && data.components[0].type !== ComponentType.ROW) {
72
- const rows = [];
73
- let newlineFlag = true;
74
- for (const comp of data.components) {
75
- if (comp.visible === false)
76
- continue; // === false to not catch any null or undefined
77
- CordoAPI.normalizeApplyFlags(comp, i ?? null, contextId, isEmphemeral);
78
- switch (comp.type) {
79
- case ComponentType.LINE_BREAK: {
80
- if (rows[rows.length - 1].length)
81
- newlineFlag = true;
82
- break;
83
- }
84
- case ComponentType.BUTTON: {
85
- if (newlineFlag)
86
- rows.push([]);
87
- newlineFlag = false;
88
- if (comp.label?.length > 50)
89
- comp.label = comp.label.substr(0, 50);
90
- rows[rows.length - 1].push(comp);
91
- if (rows[rows.length - 1].length >= 5)
92
- newlineFlag = true;
93
- break;
94
- }
95
- case ComponentType.SELECT: {
96
- if (comp.options?.length > 50)
97
- comp.options.length = 50;
98
- rows.push([comp]);
99
- newlineFlag = true;
100
- break;
101
- }
102
- case ComponentType.TEXT: {
103
- rows.push([comp]);
104
- newlineFlag = true;
105
- break;
106
- }
107
- case ComponentType.USER_SELECT: {
108
- rows.push([comp]);
109
- newlineFlag = true;
110
- break;
111
- }
112
- case ComponentType.ROLE_SELECT: {
113
- rows.push([comp]);
114
- newlineFlag = true;
115
- break;
116
- }
117
- case ComponentType.MENTIONABLE_SELECT: {
118
- rows.push([comp]);
119
- newlineFlag = true;
120
- break;
121
- }
122
- case ComponentType.CHANNEL_SELECT: {
123
- rows.push([comp]);
124
- newlineFlag = true;
125
- break;
126
- }
127
- }
128
- }
129
- data.components = rows.map(c => ({ type: ComponentType.ROW, components: c }));
130
- }
131
- }
132
- static normalizeFindAndResolveSmartEmbed(data, type) {
133
- if (type === InteractionCallbackType.PONG)
134
- return;
135
- if (type === InteractionCallbackType.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT)
136
- return;
137
- if (type === InteractionCallbackType.MODAL)
138
- return;
139
- if (!data.content)
140
- data.content = '';
141
- if (!data.description && !data.title)
142
- return;
143
- if (!data.embeds)
144
- data.embeds = [];
145
- data.embeds.push({
146
- title: data.title || undefined,
147
- description: data.description || undefined,
148
- footer: data.footer ? { text: data.footer } : undefined,
149
- image: data.image ? { url: data.image } : undefined,
150
- thumbnail: data.thumbnail ? { url: data.thumbnail } : undefined,
151
- color: data.color || 0x2b2d31
152
- });
153
- delete data.description;
154
- delete data.title;
155
- }
156
- static normalizeApplyFlags(comp, i, contextId, isEmphemeral) {
157
- if (comp.type === ComponentType.LINE_BREAK)
158
- return;
159
- if (comp.type === ComponentType.TEXT)
160
- return;
161
- if (!comp.custom_id)
162
- return;
163
- const hasAccessEveryoneFlag = comp.flags?.includes(InteractionComponentFlag.ACCESS_EVERYONE);
164
- if (isEmphemeral && !hasAccessEveryoneFlag) {
165
- if (!comp.flags)
166
- comp.flags = [];
167
- comp.flags.push(InteractionComponentFlag.ACCESS_EVERYONE);
168
- }
169
- ;
170
- comp.custom_id = CordoAPI.compileCustomId(comp.custom_id, comp.flags, contextId);
171
- if (comp.flags?.length && i && !!i.member && !hasAccessEveryoneFlag) {
172
- const perms = BigInt(i.member.permissions);
173
- if (comp.flags.includes(InteractionComponentFlag.ACCESS_ADMIN) && !PermissionStrings.containsAdmin(perms)) {
174
- if (comp.flags.includes(InteractionComponentFlag.HIDE_IF_NOT_ALLOWED))
175
- comp.type = null;
176
- else
177
- comp.disabled = true;
178
- }
179
- else if (comp.flags.includes(InteractionComponentFlag.ACCESS_MANAGE_SERVER) && !PermissionStrings.containsManageServer(perms)) {
180
- if (comp.flags.includes(InteractionComponentFlag.HIDE_IF_NOT_ALLOWED))
181
- comp.type = null;
182
- else
183
- comp.disabled = true;
184
- }
185
- else if (comp.flags.includes(InteractionComponentFlag.ACCESS_MANAGE_MESSAGES) && !PermissionStrings.containsManageMessages(perms)) {
186
- if (comp.flags.includes(InteractionComponentFlag.HIDE_IF_NOT_ALLOWED))
187
- comp.type = null;
188
- else
189
- comp.disabled = true;
190
- }
191
- else if (comp.flags.includes(InteractionComponentFlag.ACCESS_BOT_ADMIN) && !PermissionChecks.isBotOwner(i.user.id)) {
192
- if (comp.flags.includes(InteractionComponentFlag.HIDE_IF_NOT_ALLOWED))
193
- comp.type = null;
194
- else
195
- comp.disabled = true;
196
- }
197
- delete comp.flags;
198
- }
199
- }
200
- //
201
- static compileCustomId(customId, flags, contextId) {
202
- return `${contextId ?? ''}::${customId}:${flags?.join('') ?? ''}`;
203
- }
204
- static parseCustomId(rawId) {
205
- const [contextId, _reserved, customId, flagsRaw] = rawId.split(':');
206
- return { contextId, _reserved, customId, flags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