Fixed loopAll() async errors
This commit is contained in:
@@ -371,7 +371,7 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
|
||||
return this.#data.map((d) => d.id)
|
||||
}
|
||||
/**Run an iterator over all data in this manager. This method also supports async-await behaviour!*/
|
||||
async forEach(cb:(data:DataType,id:ODId) => ODPromiseVoid): Promise<void> {
|
||||
async loopAll(cb:(data:DataType,id:ODId) => ODPromiseVoid): Promise<void> {
|
||||
for (const data of this.getAll()){
|
||||
await cb(data,data.id)
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class ODCheckerManager extends ODManager<ODChecker> {
|
||||
if (!res.valid) isValid = false
|
||||
})
|
||||
|
||||
this.functions.forEach((func) => {
|
||||
this.functions.loopAll((func) => {
|
||||
const res = func.func(this,this.functions)
|
||||
final.push(...res.messages)
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ export class ODSlashCommandManager extends ODManager<ODSlashCommand> {
|
||||
const existing: {cmd:ODSlashCommand, requiresUpdate:boolean}[] = []
|
||||
const nonExisting: ODSlashCommand[] = []
|
||||
|
||||
this.forEach((cmd) => {
|
||||
this.loopAll((cmd) => {
|
||||
if (guildId && cmd.guildId != guildId) return
|
||||
const result = cmds.find((cmddata) => cmddata.name == cmd.name)
|
||||
if (result){
|
||||
@@ -977,7 +977,7 @@ export class ODTextCommandManager extends ODManager<ODTextCommand> {
|
||||
|
||||
//filter commands for correct prefix
|
||||
const validPrefixCommands: {cmd:ODTextCommand,newContent:string}[] = []
|
||||
this.forEach((cmd) => {
|
||||
this.loopAll((cmd) => {
|
||||
if (msg.content.startsWith(cmd.builder.prefix)) validPrefixCommands.push({
|
||||
cmd:cmd,
|
||||
newContent:msg.content.substring(cmd.builder.prefix.length)
|
||||
|
||||
@@ -139,7 +139,7 @@ export class ODCounterCooldown extends ODCooldown<{value:number}> {
|
||||
async init(){
|
||||
if (this.ready) return
|
||||
setInterval(() => {
|
||||
this.data.forEach((cooldown) => {
|
||||
this.data.loopAll((cooldown) => {
|
||||
cooldown.data.value = cooldown.data.value - this.decrement
|
||||
if (cooldown.data.value <= this.cancelLimit){
|
||||
cooldown.active = false
|
||||
@@ -217,7 +217,7 @@ export class ODIncrementalCounterCooldown extends ODCooldown<{value:number}> {
|
||||
async init(){
|
||||
if (this.ready) return
|
||||
setInterval(() => {
|
||||
this.data.forEach((cooldown) => {
|
||||
this.data.loopAll((cooldown) => {
|
||||
cooldown.data.value = cooldown.data.value - this.decrement
|
||||
if (cooldown.data.value <= this.cancelLimit){
|
||||
cooldown.active = false
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ODFlagManager extends ODManager<ODFlag> {
|
||||
|
||||
/**Set all flags to their `process.argv` value. */
|
||||
init(){
|
||||
this.forEach((flag) => {
|
||||
this.loopAll((flag) => {
|
||||
flag.detectProcessParams(false)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ const preloadMigrationContext = async () => {
|
||||
|
||||
const unloadMigrationContext = async () => {
|
||||
openticket.debug.visible = false
|
||||
openticket.databases.forEach((database,id) => {openticket.databases.remove(id)})
|
||||
openticket.configs.forEach((config,id) => {openticket.configs.remove(id)})
|
||||
openticket.flags.forEach((flag,id) => {openticket.flags.remove(id)})
|
||||
openticket.databases.loopAll((database,id) => {openticket.databases.remove(id)})
|
||||
openticket.configs.loopAll((config,id) => {openticket.configs.remove(id)})
|
||||
openticket.flags.loopAll((flag,id) => {openticket.flags.remove(id)})
|
||||
openticket.debug.debug("-- MIGRATION CONTEXT END --")
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ const loadAllVersionMigrations = async (lastVersion:api.ODVersion) => {
|
||||
const saveAllVersionsToDatabase = async () => {
|
||||
const globalDatabase = openticket.databases.get("openticket:global")
|
||||
|
||||
openticket.versions.forEach((version,id) => {
|
||||
openticket.versions.loopAll((version,id) => {
|
||||
globalDatabase.set("openticket:last-version",id.value,version.toString())
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user