@open-discord-bots/framework 0.2.11 → 0.2.13
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/dist/api/index.d.ts +26 -26
- package/dist/api/index.js +26 -42
- package/dist/api/main.d.ts +24 -24
- package/dist/api/main.js +7 -11
- package/dist/api/modules/action.d.ts +12 -12
- package/dist/api/modules/action.js +11 -17
- package/dist/api/modules/base.d.ts +7 -5
- package/dist/api/modules/base.js +22 -67
- package/dist/api/modules/builder.d.ts +44 -44
- package/dist/api/modules/builder.js +81 -142
- package/dist/api/modules/checker.d.ts +7 -7
- package/dist/api/modules/checker.js +55 -87
- package/dist/api/modules/client.d.ts +4 -4
- package/dist/api/modules/client.js +71 -118
- package/dist/api/modules/code.d.ts +2 -2
- package/dist/api/modules/code.js +3 -8
- package/dist/api/modules/config.d.ts +2 -2
- package/dist/api/modules/config.js +21 -63
- package/dist/api/modules/console.d.ts +16 -16
- package/dist/api/modules/console.js +61 -83
- package/dist/api/modules/cooldown.d.ts +2 -2
- package/dist/api/modules/cooldown.js +13 -23
- package/dist/api/modules/database.d.ts +2 -2
- package/dist/api/modules/database.js +19 -29
- package/dist/api/modules/event.d.ts +2 -2
- package/dist/api/modules/event.js +6 -11
- package/dist/api/modules/flag.d.ts +2 -2
- package/dist/api/modules/flag.js +3 -8
- package/dist/api/modules/fuse.js +2 -7
- package/dist/api/modules/helpmenu.d.ts +2 -2
- package/dist/api/modules/helpmenu.js +8 -16
- package/dist/api/modules/language.d.ts +2 -2
- package/dist/api/modules/language.js +12 -21
- package/dist/api/modules/permission.d.ts +3 -3
- package/dist/api/modules/permission.js +9 -47
- package/dist/api/modules/plugin.d.ts +2 -2
- package/dist/api/modules/plugin.js +9 -18
- package/dist/api/modules/post.d.ts +3 -3
- package/dist/api/modules/post.js +3 -8
- package/dist/api/modules/progressbar.d.ts +2 -2
- package/dist/api/modules/progressbar.js +14 -26
- package/dist/api/modules/responder.d.ts +42 -42
- package/dist/api/modules/responder.js +79 -138
- package/dist/api/modules/session.d.ts +2 -2
- package/dist/api/modules/session.js +4 -42
- package/dist/api/modules/startscreen.d.ts +4 -4
- package/dist/api/modules/startscreen.js +28 -44
- package/dist/api/modules/statistic.d.ts +3 -3
- package/dist/api/modules/statistic.js +11 -22
- package/dist/api/modules/verifybar.d.ts +5 -5
- package/dist/api/modules/verifybar.js +6 -11
- package/dist/api/modules/worker.d.ts +15 -15
- package/dist/api/modules/worker.js +12 -17
- package/dist/cli/editConfig.d.ts +2 -2
- package/dist/cli/editConfig.js +194 -248
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +37 -62
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -13
- package/dist/startup/compilation.d.ts +1 -1
- package/dist/startup/compilation.js +35 -42
- package/dist/startup/dump.d.ts +1 -1
- package/dist/startup/dump.js +4 -41
- package/dist/startup/errorHandling.d.ts +1 -1
- package/dist/startup/errorHandling.js +2 -38
- package/dist/startup/pluginLauncher.d.ts +1 -1
- package/dist/startup/pluginLauncher.js +14 -52
- package/dist/utilities/index.d.ts +3 -3
- package/dist/utilities/index.js +20 -71
- package/package.json +5 -4
- package/src/api/index.ts +26 -26
- package/src/api/main.ts +25 -25
- package/src/api/modules/action.ts +13 -13
- package/src/api/modules/base.ts +14 -10
- package/src/api/modules/builder.ts +56 -56
- package/src/api/modules/checker.ts +7 -7
- package/src/api/modules/client.ts +18 -18
- package/src/api/modules/code.ts +2 -2
- package/src/api/modules/component.txt +350 -0
- package/src/api/modules/config.ts +3 -3
- package/src/api/modules/console.ts +28 -28
- package/src/api/modules/cooldown.ts +2 -2
- package/src/api/modules/database.ts +3 -3
- package/src/api/modules/event.ts +5 -5
- package/src/api/modules/flag.ts +2 -2
- package/src/api/modules/helpmenu.ts +4 -4
- package/src/api/modules/language.ts +3 -3
- package/src/api/modules/permission.ts +3 -3
- package/src/api/modules/plugin.ts +4 -4
- package/src/api/modules/post.ts +3 -3
- package/src/api/modules/progressbar.ts +5 -3
- package/src/api/modules/responder.ts +48 -48
- package/src/api/modules/session.ts +2 -2
- package/src/api/modules/startscreen.ts +4 -4
- package/src/api/modules/statistic.ts +3 -4
- package/src/api/modules/verifybar.ts +5 -5
- package/src/api/modules/worker.ts +25 -25
- package/src/cli/editConfig.ts +23 -37
- package/src/cli/index.ts +3 -3
- package/src/index.ts +5 -5
- package/src/startup/compilation.ts +2 -2
- package/src/startup/dump.ts +2 -2
- package/src/startup/errorHandling.ts +2 -2
- package/src/startup/pluginLauncher.ts +11 -8
- package/src/utilities/index.ts +4 -4
- package/tools/cleanup.js +1 -1
- package/tsconfig.json +2 -1
package/src/cli/editConfig.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as api from "../api/index"
|
|
2
|
-
import * as utilities from "../utilities/index"
|
|
1
|
+
import * as api from "../api/index.js"
|
|
2
|
+
import * as utilities from "../utilities/index.js"
|
|
3
3
|
import {Terminal, terminal} from "terminal-kit"
|
|
4
4
|
import ansis from "ansis"
|
|
5
|
-
import {ODCliHeaderOpts, renderHeader} from "."
|
|
5
|
+
import {ODCliHeaderOpts, renderHeader} from "./index.js"
|
|
6
6
|
|
|
7
7
|
export class ODCliEditConfigInstance {
|
|
8
8
|
private readonly opts: ODCliHeaderOpts
|
|
@@ -37,7 +37,7 @@ export class ODCliEditConfigInstance {
|
|
|
37
37
|
await this.chooseConfigStructure(checker,async () => {await this.renderEditConfig(backFn)},checker.structure,configData,{},NaN,["("+checker.config.path+")"])
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
private async chooseConfigStructure(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerStructure,data:api.ODValidJsonType,parent:
|
|
40
|
+
private async chooseConfigStructure(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerStructure,data:api.ODValidJsonType,parent:Record<string,any>|any[],parentIndex:string|number,path:(string|number)[]){
|
|
41
41
|
if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data) await this.renderConfigObjectStructureSelector(checker,backFn,structure,data,parent,parentIndex,path)
|
|
42
42
|
else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) await this.renderConfigEnabledObjectStructureSelector(checker,backFn,structure,data,parent,parentIndex,path)
|
|
43
43
|
else if (structure instanceof api.ODCheckerObjectSwitchStructure && typeof data == "object" && !Array.isArray(data) && data) await this.renderConfigObjectSwitchStructureSelector(checker,backFn,structure,data,parent,parentIndex,path)
|
|
@@ -50,7 +50,7 @@ export class ODCliEditConfigInstance {
|
|
|
50
50
|
else terminal.red.bold("❌ Unable to detect type of variable! Please try to edit this property in the JSON file itself!")
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
private async renderConfigObjectStructureSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerObjectStructure,data:
|
|
53
|
+
private async renderConfigObjectStructureSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerObjectStructure,data:Record<string,any>,parent:Record<string,any>,parentIndex:string|number,path:(string|number)[]){
|
|
54
54
|
if (typeof data != "object" || Array.isArray(data)) throw new api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: "+parentIndex+", path: "+path.join(".")+")")
|
|
55
55
|
renderHeader(this.opts,path)
|
|
56
56
|
terminal(ansis.bold.green("Please select which variable you would like to edit.\n")+ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"))
|
|
@@ -81,7 +81,7 @@ export class ODCliEditConfigInstance {
|
|
|
81
81
|
await this.chooseConfigStructure(checker,async () => {await this.renderConfigObjectStructureSelector(checker,backFn,structure,data,parent,parentIndex,path)},subStructure.checker,subData,data,subStructure.key,[...path,subStructure.key])
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
private async renderConfigEnabledObjectStructureSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerEnabledObjectStructure,data:
|
|
84
|
+
private async renderConfigEnabledObjectStructureSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerEnabledObjectStructure,data:Record<string,any>,parent:Record<string,any>,parentIndex:string|number,path:(string|number)[]){
|
|
85
85
|
if (typeof data != "object" || Array.isArray(data)) throw new api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: "+parentIndex+", path: "+path.join(".")+")")
|
|
86
86
|
const enabledProperty = structure.options.property
|
|
87
87
|
const subStructure = structure.options.checker
|
|
@@ -96,7 +96,7 @@ export class ODCliEditConfigInstance {
|
|
|
96
96
|
await this.chooseConfigStructure(checker,backFn,subStructure,data,parent,parentIndex,path)
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
private async renderConfigObjectSwitchStructureSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerObjectSwitchStructure,data:
|
|
99
|
+
private async renderConfigObjectSwitchStructureSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerObjectSwitchStructure,data:Record<string,any>,parent:Record<string,any>,parentIndex:string|number,path:(string|number)[]){
|
|
100
100
|
if (typeof data != "object" || Array.isArray(data)) throw new api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: "+parentIndex+", path: "+path.join(".")+")")
|
|
101
101
|
if (!structure.options.objects) return await backFn()
|
|
102
102
|
|
|
@@ -174,7 +174,7 @@ export class ODCliEditConfigInstance {
|
|
|
174
174
|
await this.chooseConfigStructure(checker,async () => {await this.renderConfigArrayStructureEditSelector(checker,backFn,arrayStructure,structure,data,parent,parentIndex,path)},structure,subData,data,dataAnswer.selectedIndex,[...path,dataAnswer.selectedIndex])
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
private async renderConfigArrayStructureMoveSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),arrayStructure:api.ODCheckerArrayStructure,structure:api.ODCheckerStructure,data:any[],parent:
|
|
177
|
+
private async renderConfigArrayStructureMoveSelector(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),arrayStructure:api.ODCheckerArrayStructure,structure:api.ODCheckerStructure,data:any[],parent:Record<string,any>,parentIndex:string|number,path:(string|number)[]): Promise<void> {
|
|
178
178
|
const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index"
|
|
179
179
|
renderHeader(this.opts,path)
|
|
180
180
|
terminal(ansis.bold.green("Please select the "+propertyName+" you would like to move.\n")+ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"))
|
|
@@ -267,7 +267,7 @@ export class ODCliEditConfigInstance {
|
|
|
267
267
|
await backFn()
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
private async renderConfigBooleanStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerBooleanStructure,data:boolean,parent:
|
|
270
|
+
private async renderConfigBooleanStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerBooleanStructure,data:boolean,parent:Record<string,any>,parentIndex:string|number,path:(string|number)[]){
|
|
271
271
|
if (typeof data != "boolean") throw new api.ODSystemError("OD CLI => Property is not of the type 'boolean'. Please check your config for possible errors. (index: "+parentIndex+", path: "+path.join(".")+")")
|
|
272
272
|
renderHeader(this.opts,path)
|
|
273
273
|
terminal(ansis.bold.green("You are now editing "+(typeof parentIndex == "string" ? "the boolean property "+ansis.blue("\""+parentIndex+"\"") : "boolean property "+ansis.blue("#"+(parentIndex+1)))+".\n")+ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"))
|
|
@@ -309,7 +309,7 @@ export class ODCliEditConfigInstance {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
private async renderConfigNumberStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerNumberStructure,data:number,parent:
|
|
312
|
+
private async renderConfigNumberStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerNumberStructure,data:number,parent:Record<string,any>,parentIndex:string|number,path:(string|number)[],prefillValue?:string){
|
|
313
313
|
if (typeof data != "number") throw new api.ODSystemError("OD CLI => Property is not of the type 'number'. Please check your config for possible errors. (index: "+parentIndex+", path: "+path.join(".")+")")
|
|
314
314
|
renderHeader(this.opts,path)
|
|
315
315
|
terminal(ansis.bold.green("You are now editing "+(typeof parentIndex == "string" ? "the number property "+ansis.blue("\""+parentIndex+"\"") : "number property "+ansis.blue("#"+(parentIndex+1)))+".\n")+ansis.italic.gray("(insert a new value and press enter, go back using escape)\n"))
|
|
@@ -348,7 +348,7 @@ export class ODCliEditConfigInstance {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
private async renderConfigStringStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerStringStructure,data:string,parent:
|
|
351
|
+
private async renderConfigStringStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerStringStructure,data:string,parent:Record<string,any>,parentIndex:string|number,path:(string|number)[],prefillValue?:string){
|
|
352
352
|
if (typeof data != "string") throw new api.ODSystemError("OD CLI => Property is not of the type 'string'. Please check your config for possible errors. (index: "+parentIndex+", path: "+path.join(".")+")")
|
|
353
353
|
renderHeader(this.opts,path)
|
|
354
354
|
terminal(ansis.bold.green("You are now editing "+(typeof parentIndex == "string" ? "the string property "+ansis.blue("\""+parentIndex+"\"") : "string property "+ansis.blue("#"+(parentIndex+1)))+".\n")+ansis.italic.gray("(insert a new value and press enter, go back using escape)\n"))
|
|
@@ -409,7 +409,7 @@ export class ODCliEditConfigInstance {
|
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
private async renderConfigNullStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerNullStructure,data:null,parent:
|
|
412
|
+
private async renderConfigNullStructureEditor(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),structure:api.ODCheckerNullStructure,data:null,parent:Record<string,any>,parentIndex:string|number,path:(string|number)[]){
|
|
413
413
|
if (data !== null) throw new api.ODSystemError("OD CLI => Property is not of the type 'null'. Please check your config for possible errors. (index: "+parentIndex+", path: "+path.join(".")+")")
|
|
414
414
|
renderHeader(this.opts,path)
|
|
415
415
|
terminal(ansis.bold.green("You are now editing "+(typeof parentIndex == "string" ? "the null property "+ansis.blue("\""+parentIndex+"\"") : "null property "+ansis.blue("#"+(parentIndex+1)))+".\n")+ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"))
|
|
@@ -486,7 +486,7 @@ export class ODCliEditConfigInstance {
|
|
|
486
486
|
else if (answer.selectedText.startsWith("Edit as null") && structure.options.null) await this.renderConfigNullStructureEditor(checker,async () => {await this.renderConfigTypeSwitchStructureEditor(checker,backFn,structure,data,parent,parentIndex,path)},structure.options.null,null,parent,parentIndex,path)
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
-
private getArrayPreviewStructureNameLength(structure:api.ODCheckerStructure,data:api.ODValidJsonType,parent:
|
|
489
|
+
private getArrayPreviewStructureNameLength(structure:api.ODCheckerStructure,data:api.ODValidJsonType,parent:Record<string,any>,parentIndex:string|number): number {
|
|
490
490
|
if (structure instanceof api.ODCheckerBooleanStructure && typeof data == "boolean") return data.toString().length
|
|
491
491
|
else if (structure instanceof api.ODCheckerNumberStructure && typeof data == "number") return data.toString().length
|
|
492
492
|
else if (structure instanceof api.ODCheckerStringStructure && typeof data == "string") return data.length
|
|
@@ -494,7 +494,7 @@ export class ODCliEditConfigInstance {
|
|
|
494
494
|
else if (structure instanceof api.ODCheckerArrayStructure && Array.isArray(data)) return "Array".length
|
|
495
495
|
else if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data){
|
|
496
496
|
if (!structure.options.cliDisplayKeyInParentArray) return "Object".length
|
|
497
|
-
else return data[structure.options.cliDisplayKeyInParentArray]
|
|
497
|
+
else return data[structure.options.cliDisplayKeyInParentArray]?.toString().length ?? 0
|
|
498
498
|
|
|
499
499
|
}else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data){
|
|
500
500
|
const subStructure = structure.options.checker
|
|
@@ -522,16 +522,16 @@ export class ODCliEditConfigInstance {
|
|
|
522
522
|
}else return "<unknown-property>".length
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
private getArrayPreviewFromStructure(structure:api.ODCheckerStructure,data:api.ODValidJsonType,parent:
|
|
525
|
+
private getArrayPreviewFromStructure(structure:api.ODCheckerStructure,data:api.ODValidJsonType,parent:Record<string,any>,parentIndex:string|number,nameLength:number): string {
|
|
526
526
|
if (structure instanceof api.ODCheckerBooleanStructure && typeof data == "boolean") return data.toString()
|
|
527
527
|
else if (structure instanceof api.ODCheckerNumberStructure && typeof data == "number") return data.toString()
|
|
528
528
|
else if (structure instanceof api.ODCheckerStringStructure && typeof data == "string") return data
|
|
529
529
|
else if (structure instanceof api.ODCheckerNullStructure && data === null) return "Null"
|
|
530
530
|
else if (structure instanceof api.ODCheckerArrayStructure && Array.isArray(data)) return "Array"
|
|
531
531
|
else if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data){
|
|
532
|
-
const additionalKeys = (structure.options.cliDisplayAdditionalKeysInParentArray ?? []).map((key) => key+": "+data[key]
|
|
532
|
+
const additionalKeys = (structure.options.cliDisplayAdditionalKeysInParentArray ?? []).map((key) => key+": "+data[key]?.toString()).join(", ")
|
|
533
533
|
if (!structure.options.cliDisplayKeyInParentArray) return "Object"
|
|
534
|
-
else return data[structure.options.cliDisplayKeyInParentArray]
|
|
534
|
+
else return data[structure.options.cliDisplayKeyInParentArray]?.toString().padEnd(nameLength+5," ")+ansis.gray(additionalKeys.length > 0 ? "("+additionalKeys+")" : "")
|
|
535
535
|
|
|
536
536
|
}else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data){
|
|
537
537
|
const subStructure = structure.options.checker
|
|
@@ -572,7 +572,7 @@ export class ODCliEditConfigInstance {
|
|
|
572
572
|
else await backFn()
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
private async renderAdditionConfigObjectStructure(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),nextFn:((data:any) => api.ODPromiseVoid),structure:api.ODCheckerObjectStructure,parent:object|any[],parentIndex:string|number,path:(string|number)[],localPath:(string|number)[],localData:
|
|
575
|
+
private async renderAdditionConfigObjectStructure(checker:api.ODChecker,backFn:(() => api.ODPromiseVoid),nextFn:((data:any) => api.ODPromiseVoid),structure:api.ODCheckerObjectStructure,parent:object|any[],parentIndex:string|number,path:(string|number)[],localPath:(string|number)[],localData:Record<string,any>={}){
|
|
576
576
|
const children = structure.options.children ?? []
|
|
577
577
|
const skipKeys = (structure.options.cliInitSkipKeys ?? [])
|
|
578
578
|
//add skipped properties
|
|
@@ -606,7 +606,7 @@ export class ODCliEditConfigInstance {
|
|
|
606
606
|
})
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
-
private async configureAdditionObjectProperties(checker:api.ODChecker,children:{key:string,checker:api.ODCheckerStructure}[],currentIndex:number,localData:
|
|
609
|
+
private async configureAdditionObjectProperties(checker:api.ODChecker,children:{key:string,checker:api.ODCheckerStructure}[],currentIndex:number,localData:Record<string,any>,path:(string|number)[],localPath:(string|number)[],backFn:(() => api.ODPromiseVoid),nextFn:(() => api.ODPromiseVoid)){
|
|
610
610
|
if (children.length < 1) return await nextFn()
|
|
611
611
|
|
|
612
612
|
const child = children[currentIndex]
|
|
@@ -632,22 +632,15 @@ export class ODCliEditConfigInstance {
|
|
|
632
632
|
else if (typeof enabledValue == "boolean") propertyStructure = new api.ODCheckerBooleanStructure("opendiscord:CLI-checker-enabled-object-structure",{})
|
|
633
633
|
else throw new Error("OD CLI => enabled object structure has an invalid type of enabledProperty. It must be a primitive boolean/number/string.")
|
|
634
634
|
|
|
635
|
-
const localData = {}
|
|
635
|
+
const localData: Record<string,any> = {}
|
|
636
636
|
await this.chooseAdditionConfigStructure(checker,backFn,async (data) => {
|
|
637
637
|
if (data === enabledValue) await this.renderAdditionConfigObjectStructure(checker,async () => {await this.renderAdditionConfigEnabledObjectStructure(checker,backFn,nextFn,structure,parent,parentIndex,path,localPath)},nextFn,subStructure,parent,parentIndex,path,localPath,localData)
|
|
638
638
|
else{
|
|
639
639
|
localData[enabledProperty] = data
|
|
640
640
|
//copy old object checker to new object checker => all options get de-referenced (this is needed for the new object skip keys are temporary)
|
|
641
|
-
const newStructure = new api.ODCheckerObjectStructure(subStructure.id,
|
|
641
|
+
const newStructure = new api.ODCheckerObjectStructure(subStructure.id,structuredClone(subStructure.options))
|
|
642
642
|
|
|
643
|
-
//
|
|
644
|
-
newStructure.options.children = [...subStructure.options.children]
|
|
645
|
-
newStructure.options.cliInitSkipKeys = subStructure.options.children.map((child) => child.key)
|
|
646
|
-
for (const key of Object.keys(subStructure.options)){
|
|
647
|
-
if (key != "children" && key != "cliInitSkipKeys") newStructure.options[key] = subStructure.options[key]
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
//adds all properties to object as "skipKeys", then continues to next function
|
|
643
|
+
//continues to next function
|
|
651
644
|
await this.renderAdditionConfigObjectStructure(checker,async () => {await this.renderAdditionConfigEnabledObjectStructure(checker,backFn,nextFn,structure,parent,parentIndex,path,localPath)},nextFn,newStructure,parent,parentIndex,path,localPath,localData)
|
|
652
645
|
await nextFn(localData)
|
|
653
646
|
}
|
|
@@ -672,14 +665,7 @@ export class ODCliEditConfigInstance {
|
|
|
672
665
|
|
|
673
666
|
//copy old object checker to new object checker => all options get de-referenced (this is needed for the new object switch properties which are temporary)
|
|
674
667
|
const oldStructure = objectTemplate.checker
|
|
675
|
-
const newStructure = new api.ODCheckerObjectStructure(oldStructure.id,
|
|
676
|
-
|
|
677
|
-
//copy all options over to the new checker
|
|
678
|
-
newStructure.options.children = [...oldStructure.options.children]
|
|
679
|
-
newStructure.options.cliInitSkipKeys = [...(oldStructure.options.cliInitSkipKeys ?? [])]
|
|
680
|
-
for (const key of Object.keys(oldStructure.options)){
|
|
681
|
-
if (key != "children" && key != "cliInitSkipKeys") newStructure.options[key] = oldStructure.options[key]
|
|
682
|
-
}
|
|
668
|
+
const newStructure = new api.ODCheckerObjectStructure(oldStructure.id,structuredClone(oldStructure.options))
|
|
683
669
|
|
|
684
670
|
//add the keys of the object switch properties to the 'cliInitSkipKeys' because they need to be skipped.
|
|
685
671
|
objectTemplate.properties.map((p) => p.key).forEach((p) => {
|
package/src/cli/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as api from "../api/index"
|
|
2
|
-
import * as utilities from "../utilities/index"
|
|
1
|
+
import * as api from "../api/index.js"
|
|
2
|
+
import * as utilities from "../utilities/index.js"
|
|
3
3
|
import {Terminal, terminal} from "terminal-kit"
|
|
4
4
|
import * as discord from "discord.js"
|
|
5
5
|
import ansis from "ansis"
|
|
6
6
|
import crypto from "crypto"
|
|
7
7
|
|
|
8
|
-
export * from "./editConfig"
|
|
8
|
+
export * from "./editConfig.js"
|
|
9
9
|
|
|
10
10
|
/**## ODCliHeaderOpts `interface`
|
|
11
11
|
* All metadata required for rendering the Interactive Setup CLI header.
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { loadDumpCommand } from "./startup/dump"
|
|
2
|
-
export { loadAllPlugins } from "./startup/pluginLauncher"
|
|
3
|
-
export { frameworkStartup } from "./startup/compilation"
|
|
4
|
-
export { loadErrorHandling } from "./startup/errorHandling"
|
|
5
|
-
import { checkFrameworkAllowed } from "./startup/compilation"
|
|
1
|
+
export { loadDumpCommand } from "./startup/dump.js"
|
|
2
|
+
export { loadAllPlugins } from "./startup/pluginLauncher.js"
|
|
3
|
+
export { frameworkStartup } from "./startup/compilation.js"
|
|
4
|
+
export { loadErrorHandling } from "./startup/errorHandling.js"
|
|
5
|
+
import { checkFrameworkAllowed } from "./startup/compilation.js"
|
|
6
6
|
|
|
7
7
|
//check directory structure
|
|
8
8
|
checkFrameworkAllowed()
|
|
@@ -3,7 +3,7 @@ import ts from "typescript"
|
|
|
3
3
|
import { createHash, Hash } from "crypto"
|
|
4
4
|
import nodepath from "path"
|
|
5
5
|
import ansis from "ansis"
|
|
6
|
-
import type { ODProjectType } from "../api"
|
|
6
|
+
import type { ODPluginData, ODProjectType } from "../api/index.js"
|
|
7
7
|
|
|
8
8
|
/** ## What is this?
|
|
9
9
|
* This is a function which compares `./src/` with a hash stored in `./dist/hash.txt`.
|
|
@@ -117,7 +117,7 @@ export function frameworkStartup(startupFlags:string[],project:ODProjectType,sta
|
|
|
117
117
|
const pluginJsonPath = nodepath.join(pluginPath, "plugin.json")
|
|
118
118
|
if (fs.existsSync(pluginJsonPath)){
|
|
119
119
|
try{
|
|
120
|
-
const pluginData = JSON.parse(fs.readFileSync(pluginJsonPath).toString())
|
|
120
|
+
const pluginData: ODPluginData = JSON.parse(fs.readFileSync(pluginJsonPath).toString())
|
|
121
121
|
if (pluginData.npmDependencies && Array.isArray(pluginData.npmDependencies)){
|
|
122
122
|
pluginData.npmDependencies.forEach((dep) => {
|
|
123
123
|
if (typeof dep === "string" && dep.trim()){
|
package/src/startup/dump.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as api from "../api/index"
|
|
2
|
-
import * as utilities from "../utilities/index"
|
|
1
|
+
import * as api from "../api/index.js"
|
|
2
|
+
import * as utilities from "../utilities/index.js"
|
|
3
3
|
|
|
4
4
|
export function loadErrorHandling(opendiscord:api.ODMain,project:api.ODProjectType){
|
|
5
5
|
process.on("uncaughtException",async (error,origin) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as api from "../api/index"
|
|
2
|
-
import * as utilities from "../utilities/index"
|
|
1
|
+
import * as api from "../api/index.js"
|
|
2
|
+
import * as utilities from "../utilities/index.js"
|
|
3
3
|
import fs from "fs"
|
|
4
4
|
|
|
5
5
|
export const loadAllPlugins = async (opendiscord:api.ODMain) => {
|
|
@@ -17,16 +17,19 @@ export const loadAllPlugins = async (opendiscord:api.ODMain) => {
|
|
|
17
17
|
//check & validate
|
|
18
18
|
for (const p of plugins){
|
|
19
19
|
//prechecks
|
|
20
|
-
if (p === ".DS_Store")
|
|
21
|
-
if (!fs.statSync("./plugins/"+p).isDirectory())
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (p === ".DS_Store") continue //ignore MacOS DS_Store file
|
|
21
|
+
if (!fs.statSync("./plugins/"+p).isDirectory()){
|
|
22
|
+
opendiscord.log("Plugin is not a directory, canceling plugin execution...","plugin",[
|
|
23
|
+
{key:"plugin",value:"./plugins/"+p}
|
|
24
|
+
])
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
24
27
|
if (!fs.existsSync("./plugins/"+p+"/plugin.json")){
|
|
25
28
|
initPluginError = true
|
|
26
29
|
opendiscord.log("Plugin doesn't have a plugin.json, canceling plugin execution...","plugin",[
|
|
27
30
|
{key:"plugin",value:"./plugins/"+p}
|
|
28
31
|
])
|
|
29
|
-
|
|
32
|
+
continue
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
//plugin loading
|
|
@@ -81,7 +84,7 @@ export const loadAllPlugins = async (opendiscord:api.ODMain) => {
|
|
|
81
84
|
const plugin = new api.ODPlugin(p,rawplugindata)
|
|
82
85
|
opendiscord.plugins.add(plugin)
|
|
83
86
|
|
|
84
|
-
}catch(e){
|
|
87
|
+
}catch(e:any){
|
|
85
88
|
//when any of the above errors happen, crash the bot when soft mode isn't enabled
|
|
86
89
|
initPluginError = true
|
|
87
90
|
opendiscord.log(e.message+", canceling plugin execution...","plugin",[
|
package/src/utilities/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "fs"
|
|
2
2
|
import ansis from "ansis"
|
|
3
|
-
import * as api from "../api/index"
|
|
3
|
+
import * as api from "../api/index.js"
|
|
4
4
|
|
|
5
5
|
/**## sharedFuses `utility variable`
|
|
6
6
|
* All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
|
|
@@ -107,7 +107,7 @@ export function timedAwait<ReturnValue>(promise:ReturnValue,timeout:number,onErr
|
|
|
107
107
|
try{
|
|
108
108
|
const res = await promise
|
|
109
109
|
if (allowResolve) resolve(res)
|
|
110
|
-
}catch(err){
|
|
110
|
+
}catch(err:any){
|
|
111
111
|
onError(err)
|
|
112
112
|
}
|
|
113
113
|
return promise
|
|
@@ -117,7 +117,7 @@ export function timedAwait<ReturnValue>(promise:ReturnValue,timeout:number,onErr
|
|
|
117
117
|
/**## dateString `utility function`
|
|
118
118
|
* Use this function to create a short date string in the following format: `DD/MM/YYYY HH:MM:SS`
|
|
119
119
|
*/
|
|
120
|
-
export function dateString(date): string {
|
|
120
|
+
export function dateString(date:Date): string {
|
|
121
121
|
return `${date.getDate()}/${date.getMonth()+1}/${date.getFullYear()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -162,7 +162,7 @@ export function ordinalNumber(num:number){
|
|
|
162
162
|
/**## trimEmojis `utility function`
|
|
163
163
|
* Trim/remove all emoji's from a Javascript string.
|
|
164
164
|
*/
|
|
165
|
-
export function trimEmojis(text){
|
|
165
|
+
export function trimEmojis(text:string){
|
|
166
166
|
return text.replace(/(\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?)*)/gu,"")
|
|
167
167
|
}
|
|
168
168
|
|
package/tools/cleanup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import fs from "fs"
|
|
2
2
|
fs.rmSync("./dist",{recursive: true, force:true})
|
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "es2025",
|
|
4
4
|
"strictNullChecks": true,
|
|
5
5
|
"strictPropertyInitialization": true,
|
|
6
6
|
"declaration": true,
|
|
7
7
|
"module": "NodeNext",
|
|
8
8
|
"moduleResolution": "NodeNext",
|
|
9
|
+
"rootDir": "./src",
|
|
9
10
|
"outDir": "./dist"
|
|
10
11
|
},
|
|
11
12
|
"include": [
|