@open-discord-bots/framework 0.2.17 → 0.3.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/dist/api/index.d.ts +16 -15
- package/dist/api/index.js +16 -15
- package/dist/api/main.d.ts +31 -23
- package/dist/api/main.js +3 -1
- package/dist/api/modules/action.d.ts +2 -2
- package/dist/api/modules/action.js +1 -5
- package/dist/api/modules/base.d.ts +29 -11
- package/dist/api/modules/base.js +78 -80
- package/dist/api/modules/builder.d.ts +2 -11
- package/dist/api/modules/builder.js +0 -4
- package/dist/api/modules/checker.d.ts +28 -7
- package/dist/api/modules/checker.js +33 -37
- package/dist/api/modules/client.d.ts +66 -14
- package/dist/api/modules/client.js +146 -132
- package/dist/api/modules/component.d.ts +928 -0
- package/dist/api/modules/component.js +1346 -0
- package/dist/api/modules/config.d.ts +30 -2
- package/dist/api/modules/config.js +90 -7
- package/dist/api/modules/console.d.ts +16 -4
- package/dist/api/modules/console.js +25 -25
- package/dist/api/modules/cooldown.d.ts +5 -5
- package/dist/api/modules/cooldown.js +1 -17
- package/dist/api/modules/database.d.ts +21 -13
- package/dist/api/modules/database.js +0 -23
- package/dist/api/modules/event.d.ts +4 -2
- package/dist/api/modules/event.js +8 -10
- package/dist/api/modules/fuse.d.ts +1 -1
- package/dist/api/modules/helpmenu.d.ts +11 -9
- package/dist/api/modules/helpmenu.js +24 -22
- package/dist/api/modules/language.d.ts +4 -3
- package/dist/api/modules/language.js +9 -16
- package/dist/api/modules/permission.d.ts +10 -1
- package/dist/api/modules/permission.js +17 -20
- package/dist/api/modules/plugin.d.ts +2 -1
- package/dist/api/modules/plugin.js +2 -2
- package/dist/api/modules/post.d.ts +12 -4
- package/dist/api/modules/post.js +36 -10
- package/dist/api/modules/progressbar.d.ts +18 -6
- package/dist/api/modules/progressbar.js +35 -35
- package/dist/api/modules/responder.d.ts +97 -28
- package/dist/api/modules/responder.js +213 -176
- package/dist/api/modules/session.d.ts +11 -2
- package/dist/api/modules/session.js +16 -16
- package/dist/api/modules/startscreen.d.ts +2 -3
- package/dist/api/modules/startscreen.js +8 -9
- package/dist/api/modules/statistic.d.ts +2 -1
- package/dist/api/modules/statistic.js +4 -7
- package/dist/api/modules/worker.d.ts +2 -1
- package/dist/api/modules/worker.js +3 -3
- package/package.json +3 -2
- package/src/api/index.ts +16 -15
- package/src/api/main.ts +33 -24
- package/src/api/modules/action.ts +2 -4
- package/src/api/modules/base.ts +77 -79
- package/src/api/modules/builder.ts +2 -14
- package/src/api/modules/checker.ts +36 -37
- package/src/api/modules/client.ts +144 -136
- package/src/api/modules/component.ts +1826 -0
- package/src/api/modules/config.ts +86 -7
- package/src/api/modules/console.ts +25 -25
- package/src/api/modules/cooldown.ts +8 -13
- package/src/api/modules/database.ts +24 -32
- package/src/api/modules/event.ts +6 -10
- package/src/api/modules/fuse.ts +1 -1
- package/src/api/modules/helpmenu.ts +31 -27
- package/src/api/modules/language.ts +11 -16
- package/src/api/modules/permission.ts +17 -20
- package/src/api/modules/plugin.ts +2 -2
- package/src/api/modules/post.ts +31 -10
- package/src/api/modules/progressbar.ts +36 -37
- package/src/api/modules/responder.ts +234 -185
- package/src/api/modules/session.ts +15 -15
- package/src/api/modules/startscreen.ts +9 -10
- package/src/api/modules/statistic.ts +4 -7
- package/src/api/modules/worker.ts +3 -3
- package/src/api/modules/component.txt +0 -350
package/src/api/modules/base.ts
CHANGED
|
@@ -64,18 +64,10 @@ export type ODNoGeneric<T extends Record<string|number|symbol,any>> = {
|
|
|
64
64
|
* You can use this class to assign a unique id when creating configs, databases, languages & more!
|
|
65
65
|
*/
|
|
66
66
|
export class ODId {
|
|
67
|
-
/**The
|
|
68
|
-
|
|
69
|
-
/**The full value of this `ODId` as a `string`. */
|
|
70
|
-
set value(id:string){
|
|
71
|
-
this._change(this.#value,id)
|
|
72
|
-
this.#value = id
|
|
73
|
-
}
|
|
74
|
-
get value(){
|
|
75
|
-
return this.#value
|
|
76
|
-
}
|
|
67
|
+
/**The raw value of this `ODId` as a `string`. */
|
|
68
|
+
private rawValue: string
|
|
77
69
|
/**The change listener for the parent `ODManager` of this `ODId`. */
|
|
78
|
-
|
|
70
|
+
private changeListener: ((oldId:string,newId:string) => void)|null = null
|
|
79
71
|
|
|
80
72
|
constructor(id:ODValidId){
|
|
81
73
|
if (typeof id != "string" && !(id instanceof ODId)) throw new ODSystemError("Invalid constructor parameter => id:ODValidId")
|
|
@@ -91,37 +83,45 @@ export class ODId {
|
|
|
91
83
|
}
|
|
92
84
|
})
|
|
93
85
|
|
|
94
|
-
if (result.length > 0) this
|
|
86
|
+
if (result.length > 0) this.rawValue = result.join("")
|
|
95
87
|
else throw new ODSystemError("invalid ID at 'new ODID(id: "+id+")'")
|
|
96
88
|
}else{
|
|
97
89
|
//id is ODId
|
|
98
|
-
this
|
|
90
|
+
this.rawValue = id.rawValue
|
|
99
91
|
}
|
|
100
92
|
}
|
|
101
93
|
|
|
94
|
+
/**The full value of this `ODId` as a `string`. */
|
|
95
|
+
set value(id:string){
|
|
96
|
+
this._change(this.rawValue,id)
|
|
97
|
+
this.rawValue = id
|
|
98
|
+
}
|
|
99
|
+
get value(){
|
|
100
|
+
return this.rawValue
|
|
101
|
+
}
|
|
102
102
|
/**Returns a string representation of this id. (same as `this.value`) */
|
|
103
103
|
toString(){
|
|
104
|
-
return this
|
|
104
|
+
return this.rawValue
|
|
105
105
|
}
|
|
106
106
|
/**The namespace of the id before `:`. (e.g. `opendiscord` for `opendiscord:autoclose-enabled`) */
|
|
107
107
|
getNamespace(){
|
|
108
|
-
const splitted = this
|
|
108
|
+
const splitted = this.rawValue.split(":")
|
|
109
109
|
if (splitted.length > 1) return splitted[0]
|
|
110
110
|
else return ""
|
|
111
111
|
}
|
|
112
112
|
/**The identifier of the id after `:`. (e.g. `autoclose-enabled` for `opendiscord:autoclose-enabled`) */
|
|
113
113
|
getIdentifier(){
|
|
114
|
-
const splitted = this
|
|
114
|
+
const splitted = this.rawValue.split(":")
|
|
115
115
|
if (splitted.length > 1){
|
|
116
116
|
splitted.shift()
|
|
117
117
|
return splitted.join(":")
|
|
118
|
-
}else return this
|
|
118
|
+
}else return this.rawValue
|
|
119
119
|
}
|
|
120
120
|
/**Trigger an `onChange()` event in the parent `ODManager` of this class. */
|
|
121
121
|
protected _change(oldId:string,newId:string){
|
|
122
|
-
if (this
|
|
122
|
+
if (this.changeListener){
|
|
123
123
|
try{
|
|
124
|
-
this
|
|
124
|
+
this.changeListener(oldId,newId)
|
|
125
125
|
}catch(err){
|
|
126
126
|
process.emit("uncaughtException",err)
|
|
127
127
|
throw new ODSystemError("Failed to execute _change() callback!")
|
|
@@ -130,7 +130,7 @@ export class ODId {
|
|
|
130
130
|
}
|
|
131
131
|
/****(❌ SYSTEM ONLY!!)** Set the callback executed when a value inside this class changes. */
|
|
132
132
|
changed(callback:((oldId:string,newId:string) => void)|null){
|
|
133
|
-
this
|
|
133
|
+
this.changeListener = callback
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -140,14 +140,14 @@ export class ODId {
|
|
|
140
140
|
* It is used to let the "onChange" event in the `ODManager` class work.
|
|
141
141
|
* You can use this class when extending your own `ODManager`
|
|
142
142
|
*/
|
|
143
|
-
export class ODManagerChangeHelper {
|
|
144
|
-
|
|
143
|
+
export abstract class ODManagerChangeHelper {
|
|
144
|
+
private changeListener: (() => void)|null = null
|
|
145
145
|
|
|
146
146
|
/**Trigger an `onChange()` event in the parent `ODManager` of this class. */
|
|
147
147
|
protected _change(){
|
|
148
|
-
if (this
|
|
148
|
+
if (this.changeListener){
|
|
149
149
|
try{
|
|
150
|
-
this
|
|
150
|
+
this.changeListener()
|
|
151
151
|
}catch(err){
|
|
152
152
|
process.emit("uncaughtException",err)
|
|
153
153
|
throw new ODSystemError("Failed to execute _change() callback!")
|
|
@@ -156,7 +156,7 @@ export class ODManagerChangeHelper {
|
|
|
156
156
|
}
|
|
157
157
|
/****(❌ SYSTEM ONLY!!)** Set the callback executed when a value inside this class changes. */
|
|
158
158
|
changed(callback:(() => void)|null){
|
|
159
|
-
this
|
|
159
|
+
this.changeListener = callback
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -167,7 +167,7 @@ export class ODManagerChangeHelper {
|
|
|
167
167
|
*
|
|
168
168
|
* There is an `id:ODId` property & also some events used in the manager.
|
|
169
169
|
*/
|
|
170
|
-
export class ODManagerData extends ODManagerChangeHelper {
|
|
170
|
+
export abstract class ODManagerData extends ODManagerChangeHelper {
|
|
171
171
|
/**The id of this data. */
|
|
172
172
|
id: ODId
|
|
173
173
|
|
|
@@ -198,22 +198,22 @@ export type ODManagerAddCallback<DataType extends ODManagerData> = (data:DataTyp
|
|
|
198
198
|
*/
|
|
199
199
|
export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHelper {
|
|
200
200
|
/**Alias to Open Discord debugger. */
|
|
201
|
-
|
|
201
|
+
protected debug?: ODDebugger
|
|
202
202
|
/**The message to send when debugging this manager. */
|
|
203
|
-
|
|
203
|
+
protected debugname?: string
|
|
204
204
|
/**The map storing all data classes in this manager. */
|
|
205
|
-
|
|
205
|
+
private data: Map<string,DataType> = new Map()
|
|
206
206
|
/**An array storing all listeners when data is added. */
|
|
207
|
-
|
|
207
|
+
private addListeners: ODManagerAddCallback<DataType>[] = []
|
|
208
208
|
/**An array storing all listeners when data has changed. */
|
|
209
|
-
|
|
209
|
+
private changeListeners: ODManagerCallback<DataType>[] = []
|
|
210
210
|
/**An array storing all listeners when data is removed. */
|
|
211
|
-
|
|
211
|
+
private removeListeners: ODManagerCallback<DataType>[] = []
|
|
212
212
|
|
|
213
213
|
constructor(debug?:ODDebugger, debugname?:string){
|
|
214
|
-
|
|
215
|
-
this
|
|
216
|
-
this
|
|
214
|
+
super()
|
|
215
|
+
this.debug = debug
|
|
216
|
+
this.debugname = debugname
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**Add data to the manager. The `ODId` in the data class will be used as identifier! You can optionally select to overwrite existing data!*/
|
|
@@ -228,22 +228,22 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
228
228
|
|
|
229
229
|
//add listener for data id change => transfer data within manager
|
|
230
230
|
data.id.changed((oldId,newId) => {
|
|
231
|
-
this
|
|
232
|
-
this
|
|
231
|
+
this.data.delete(oldId)
|
|
232
|
+
this.data.set(newId,data)
|
|
233
233
|
})
|
|
234
234
|
|
|
235
235
|
//add data
|
|
236
236
|
let didOverwrite: boolean
|
|
237
|
-
if (this
|
|
238
|
-
if (!overwrite) throw new ODSystemError("Id '"+data.id.value+"' already exists in "+this
|
|
239
|
-
this
|
|
237
|
+
if (this.data.has(data.id.value)){
|
|
238
|
+
if (!overwrite) throw new ODSystemError("Id '"+data.id.value+"' already exists in "+this.debugname+" manager. Use 'overwrite:true' to allow overwriting!")
|
|
239
|
+
this.data.set(data.id.value,data)
|
|
240
240
|
didOverwrite = true
|
|
241
|
-
if (this
|
|
241
|
+
if (this.debug) this.debug.debug("Added new "+this.debugname+" to manager",[{key:"id",value:data.id.value},{key:"overwrite",value:"true"}])
|
|
242
242
|
|
|
243
243
|
}else{
|
|
244
|
-
this
|
|
244
|
+
this.data.set(data.id.value,data)
|
|
245
245
|
didOverwrite = false
|
|
246
|
-
if (this
|
|
246
|
+
if (this.debug) this.debug.debug("Added new "+this.debugname+" to manager",[{key:"id",value:data.id.value},{key:"overwrite",value:"false"}])
|
|
247
247
|
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -251,7 +251,7 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
251
251
|
data.changed(() => {
|
|
252
252
|
//notify change in upper-manager (because data in this manager changed)
|
|
253
253
|
this._change()
|
|
254
|
-
this
|
|
254
|
+
this.changeListeners.forEach((cb) => {
|
|
255
255
|
try{
|
|
256
256
|
cb(data)
|
|
257
257
|
}catch(err){
|
|
@@ -261,7 +261,7 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
261
261
|
})
|
|
262
262
|
|
|
263
263
|
//emit add listeners
|
|
264
|
-
this
|
|
264
|
+
this.addListeners.forEach((cb) => {
|
|
265
265
|
try{
|
|
266
266
|
cb(data,didOverwrite)
|
|
267
267
|
}catch(err){
|
|
@@ -277,21 +277,21 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
277
277
|
/**Get data that matches the `ODId`. Returns the found data.*/
|
|
278
278
|
get(id:ODValidId): DataType|null {
|
|
279
279
|
const newId = new ODId(id)
|
|
280
|
-
const data = this
|
|
280
|
+
const data = this.data.get(newId.value)
|
|
281
281
|
if (data) return data
|
|
282
282
|
else return null
|
|
283
283
|
}
|
|
284
284
|
/**Remove data that matches the `ODId`. Returns the removed data. */
|
|
285
285
|
remove(id:ODValidId): DataType|null {
|
|
286
286
|
const newId = new ODId(id)
|
|
287
|
-
const data = this
|
|
287
|
+
const data = this.data.get(newId.value)
|
|
288
288
|
|
|
289
289
|
if (!data){
|
|
290
|
-
if (this
|
|
290
|
+
if (this.debug) this.debug.debug("Removed "+this.debugname+" from manager",[{key:"id",value:newId.value},{key:"found",value:"false"}])
|
|
291
291
|
return null
|
|
292
292
|
}else{
|
|
293
|
-
this
|
|
294
|
-
if (this
|
|
293
|
+
this.data.delete(newId.value)
|
|
294
|
+
if (this.debug) this.debug.debug("Removed "+this.debugname+" from manager",[{key:"id",value:newId.value},{key:"found",value:"true"}])
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
//remove all listeners
|
|
@@ -299,7 +299,7 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
299
299
|
data.changed(null)
|
|
300
300
|
|
|
301
301
|
//emit remove listeners
|
|
302
|
-
this
|
|
302
|
+
this.removeListeners.forEach((cb) => {
|
|
303
303
|
try{
|
|
304
304
|
cb(data)
|
|
305
305
|
}catch(err){
|
|
@@ -315,28 +315,28 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
315
315
|
/**Check if data that matches the `ODId` exists. Returns a boolean. */
|
|
316
316
|
exists(id:ODValidId): boolean {
|
|
317
317
|
const newId = new ODId(id)
|
|
318
|
-
if (this
|
|
318
|
+
if (this.data.has(newId.value)) return true
|
|
319
319
|
else return false
|
|
320
320
|
}
|
|
321
321
|
/**Get all data inside this manager*/
|
|
322
322
|
getAll(): DataType[] {
|
|
323
|
-
return Array.from(this
|
|
323
|
+
return Array.from(this.data.values())
|
|
324
324
|
}
|
|
325
325
|
/**Get all data that matches inside the filter function*/
|
|
326
326
|
getFiltered(predicate:(value:DataType, index:number, array:DataType[]) => unknown): DataType[] {
|
|
327
|
-
return Array.from(this
|
|
327
|
+
return Array.from(this.data.values()).filter(predicate)
|
|
328
328
|
}
|
|
329
329
|
/**Get all data where the `ODId` matches the provided RegExp. */
|
|
330
330
|
getRegex(regex:RegExp): DataType[] {
|
|
331
|
-
return Array.from(this
|
|
331
|
+
return Array.from(this.data.values()).filter((data) => regex.test(data.id.value))
|
|
332
332
|
}
|
|
333
333
|
/**Get the length/size/amount of the data inside this manager. */
|
|
334
334
|
getLength(){
|
|
335
|
-
return this
|
|
335
|
+
return this.data.size
|
|
336
336
|
}
|
|
337
337
|
/**Get a list of all the ids inside this manager*/
|
|
338
338
|
getIds(): ODId[] {
|
|
339
|
-
const ids = Array.from(this
|
|
339
|
+
const ids = Array.from(this.data.keys())
|
|
340
340
|
return ids.map((id) => new ODId(id))
|
|
341
341
|
}
|
|
342
342
|
/**Run an iterator over all data in this manager. This method also supports async-await behaviour!*/
|
|
@@ -347,20 +347,20 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
347
347
|
}
|
|
348
348
|
/**Use the Open Discord debugger in this manager for logs*/
|
|
349
349
|
useDebug(debug?:ODDebugger, debugname?:string){
|
|
350
|
-
this
|
|
351
|
-
this
|
|
350
|
+
this.debug = debug
|
|
351
|
+
this.debugname = debugname
|
|
352
352
|
}
|
|
353
353
|
/**Listen for when data is added to this manager. */
|
|
354
354
|
onAdd(callback:ODManagerAddCallback<DataType>){
|
|
355
|
-
this
|
|
355
|
+
this.addListeners.push(callback)
|
|
356
356
|
}
|
|
357
357
|
/**Listen for when data is changed in this manager. */
|
|
358
358
|
onChange(callback:ODManagerCallback<DataType>){
|
|
359
|
-
this
|
|
359
|
+
this.changeListeners.push(callback)
|
|
360
360
|
}
|
|
361
361
|
/**Listen for when data is removed from this manager. */
|
|
362
362
|
onRemove(callback:ODManagerCallback<DataType>){
|
|
363
|
-
this
|
|
363
|
+
this.removeListeners.push(callback)
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -372,14 +372,11 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
|
|
372
372
|
*/
|
|
373
373
|
export class ODManagerWithSafety<DataType extends ODManagerData> extends ODManager<DataType> {
|
|
374
374
|
/**The function that creates backup data returned in `getSafe()` when an id is missing in this manager. */
|
|
375
|
-
|
|
376
|
-
/** Temporary storage for manager debug name. */
|
|
377
|
-
#debugname: string
|
|
375
|
+
protected backupGenerator: () => DataType
|
|
378
376
|
|
|
379
|
-
constructor(
|
|
377
|
+
constructor(backupGenerator:() => DataType, debug?:ODDebugger, debugname?:string){
|
|
380
378
|
super(debug,debugname)
|
|
381
|
-
this
|
|
382
|
-
this.#debugname = debugname ?? "unknown"
|
|
379
|
+
this.backupGenerator = backupGenerator
|
|
383
380
|
}
|
|
384
381
|
|
|
385
382
|
/**Get data that matches the `ODId`. Returns the backup data when not found.
|
|
@@ -390,8 +387,8 @@ export class ODManagerWithSafety<DataType extends ODManagerData> extends ODManag
|
|
|
390
387
|
const newId = new ODId(id)
|
|
391
388
|
const data = super.get(id)
|
|
392
389
|
if (!data){
|
|
393
|
-
process.emit("uncaughtException",new ODSystemError("ODManagerWithSafety:getSafe(\""+newId.value+"\") => Unknown Id => Used backup data ("+this
|
|
394
|
-
return this
|
|
390
|
+
process.emit("uncaughtException",new ODSystemError("ODManagerWithSafety:getSafe(\""+newId.value+"\") => Unknown Id => Used backup data ("+this.debugname+" manager)"))
|
|
391
|
+
return this.backupGenerator()
|
|
395
392
|
}
|
|
396
393
|
else return data
|
|
397
394
|
}
|
|
@@ -578,19 +575,19 @@ export class ODVersionMigration {
|
|
|
578
575
|
/**The version to migrate data to */
|
|
579
576
|
version: ODVersion
|
|
580
577
|
/**The migration function */
|
|
581
|
-
|
|
578
|
+
private migrateFunc: () => void|Promise<void>
|
|
582
579
|
/**The migration function */
|
|
583
|
-
|
|
580
|
+
private migrateAfterInitFunc: () => void|Promise<void>
|
|
584
581
|
|
|
585
|
-
constructor(version:ODVersion,
|
|
582
|
+
constructor(version:ODVersion,migrateFunc:() => void|Promise<void>,migrateAfterInitFunc:() => void|Promise<void>){
|
|
586
583
|
this.version = version
|
|
587
|
-
this
|
|
588
|
-
this
|
|
584
|
+
this.migrateFunc = migrateFunc
|
|
585
|
+
this.migrateAfterInitFunc = migrateAfterInitFunc
|
|
589
586
|
}
|
|
590
587
|
/**Run this version migration as a plugin. Returns `false` when something goes wrong. */
|
|
591
588
|
async migrate(): Promise<boolean> {
|
|
592
589
|
try{
|
|
593
|
-
await this
|
|
590
|
+
await this.migrateFunc()
|
|
594
591
|
return true
|
|
595
592
|
}catch(err){
|
|
596
593
|
process.emit("uncaughtException",err)
|
|
@@ -600,7 +597,7 @@ export class ODVersionMigration {
|
|
|
600
597
|
/**Run this version migration as a plugin (after other plugins have loaded). Returns `false` when something goes wrong. */
|
|
601
598
|
async migrateAfterInit(): Promise<boolean> {
|
|
602
599
|
try{
|
|
603
|
-
await this
|
|
600
|
+
await this.migrateAfterInitFunc()
|
|
604
601
|
return true
|
|
605
602
|
}catch(err){
|
|
606
603
|
process.emit("uncaughtException",err)
|
|
@@ -742,7 +739,7 @@ export class ODEnvHelper {
|
|
|
742
739
|
if (typeof customEnvPath != "undefined" && typeof customEnvPath != "string") throw new ODSystemError("Invalid constructor parameter => customEnvPath?:string")
|
|
743
740
|
|
|
744
741
|
const path = customEnvPath ? customEnvPath : ".env"
|
|
745
|
-
this.dotenv = fs.existsSync(path) ? this
|
|
742
|
+
this.dotenv = fs.existsSync(path) ? this.readDotEnv(fs.readFileSync(path)) : {}
|
|
746
743
|
this.env = process.env
|
|
747
744
|
}
|
|
748
745
|
|
|
@@ -765,7 +762,8 @@ export class ODEnvHelper {
|
|
|
765
762
|
//THIS CODE IS COPIED FROM THE DODENV-LIB
|
|
766
763
|
//Repo: https://github.com/motdotla/dotenv
|
|
767
764
|
//Source: https://github.com/motdotla/dotenv/blob/master/lib/main.js#L12
|
|
768
|
-
|
|
765
|
+
//All rights go to the original authors of the dotenv library.
|
|
766
|
+
protected readDotEnv(src:Buffer){
|
|
769
767
|
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
|
|
770
768
|
const obj: Record<string,any> = {}
|
|
771
769
|
|
|
@@ -13,7 +13,7 @@ import { ODDebugger } from "./console.js"
|
|
|
13
13
|
*
|
|
14
14
|
* This class can't be used stand-alone & needs to be extended from!
|
|
15
15
|
*/
|
|
16
|
-
export class ODBuilderImplementation<Instance,Origin extends string,Params,BuildType extends {id:ODId},WorkerIds extends string = string> extends ODManagerData {
|
|
16
|
+
export abstract class ODBuilderImplementation<Instance,Origin extends string,Params,BuildType extends {id:ODId},WorkerIds extends string = string> extends ODManagerData {
|
|
17
17
|
/**The manager that has all workers of this implementation */
|
|
18
18
|
workers: ODWorkerManager<Instance,Origin,Params,WorkerIds>
|
|
19
19
|
/**Cache a build or create it every time from scratch when this.build() gets executed. */
|
|
@@ -42,9 +42,7 @@ export class ODBuilderImplementation<Instance,Origin extends string,Params,Build
|
|
|
42
42
|
return this
|
|
43
43
|
}
|
|
44
44
|
/**Execute all workers & return the result. */
|
|
45
|
-
|
|
46
|
-
throw new ODSystemError("Tried to build an unimplemented ODBuilderImplementation")
|
|
47
|
-
}
|
|
45
|
+
abstract build(origin:Origin, params:Params): Promise<BuildType>
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
/**## ODBuilderManager `class`
|
|
@@ -1297,16 +1295,6 @@ export interface ODMessageBuildResult {
|
|
|
1297
1295
|
ephemeral:boolean
|
|
1298
1296
|
}
|
|
1299
1297
|
|
|
1300
|
-
/**## ODMessageBuildSentResult `interface`
|
|
1301
|
-
* This interface contains the result from a sent built message. This can be used to edit, view & save the message that got created.
|
|
1302
|
-
*/
|
|
1303
|
-
export interface ODMessageBuildSentResult<InGuild extends boolean> {
|
|
1304
|
-
/**Did the message get sent successfully? */
|
|
1305
|
-
success:boolean,
|
|
1306
|
-
/**The message that got sent. */
|
|
1307
|
-
message:discord.Message<InGuild>|null
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
1298
|
/**## ODMessageInstance `class`
|
|
1311
1299
|
* This is an Open Discord message instance.
|
|
1312
1300
|
*
|