diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/extensions/BotClient.ts | 17 | ||||
-rw-r--r-- | src/lib/extensions/BotTask.ts | 6 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/lib/extensions/BotClient.ts b/src/lib/extensions/BotClient.ts index bd14fd2..0b59675 100644 --- a/src/lib/extensions/BotClient.ts +++ b/src/lib/extensions/BotClient.ts @@ -2,14 +2,14 @@ import { AkairoClient, CommandHandler, InhibitorHandler, - ListenerHandler + ListenerHandler, + TaskHandler } from 'discord-akairo'; import { Guild } from 'discord.js'; import * as path from 'path'; import { Sequelize } from 'sequelize'; import * as Models from '../models'; import { Util } from './Util'; -import * as Tasks from '../../tasks'; import { exit } from 'process'; import { Intents } from 'discord.js'; import * as config from '../../config/options'; @@ -23,6 +23,7 @@ export class BotClient extends AkairoClient { public listenerHandler: ListenerHandler; public inhibitorHandler: InhibitorHandler; public commandHandler: CommandHandler; + public taskHandler: TaskHandler; public util: Util; public ownerID: string[]; public db: Sequelize; @@ -57,6 +58,11 @@ export class BotClient extends AkairoClient { automateCategories: true }); + // Create task handler + this.taskHandler = new TaskHandler(this, { + directory: path.join(__dirname, "..", "..", "tasks"), + }); + // Create command handler this.commandHandler = new CommandHandler(this, { directory: path.join(__dirname, '..', '..', 'commands'), @@ -110,7 +116,8 @@ export class BotClient extends AkairoClient { const loaders = { commands: this.commandHandler, listeners: this.listenerHandler, - inhibitors: this.inhibitorHandler + inhibitors: this.inhibitorHandler, + tasks: this.taskHandler }; for (const loader of Object.keys(loaders)) { try { @@ -126,10 +133,8 @@ export class BotClient extends AkairoClient { ); } } + this.taskHandler.startAll(); await this.dbPreInit(); - Object.keys(Tasks).forEach((t) => { - setInterval(() => Tasks[t](this), 30000); - }); } public async dbPreInit(): Promise<void> { diff --git a/src/lib/extensions/BotTask.ts b/src/lib/extensions/BotTask.ts new file mode 100644 index 0000000..c0da5d3 --- /dev/null +++ b/src/lib/extensions/BotTask.ts @@ -0,0 +1,6 @@ +import { Task } from 'discord-akairo'; +import { BotClient } from './BotClient'; + +export class BotTask extends Task { + public client: BotClient; +}
\ No newline at end of file |