diff --git a/src/class/Queue.ts b/src/class/Queue.ts index 5be214a..daf587f 100644 --- a/src/class/Queue.ts +++ b/src/class/Queue.ts @@ -15,6 +15,26 @@ export default class Queue { this.setProcessors(); } + public async jobCounts() { + const data = { + waiting: 0, + active: 0, + completed: 0, + failed: 0, + delayed: 0, + }; + for (const entry of Object.entries(this.queues)) { + // eslint-disable-next-line no-await-in-loop + const counts = await entry[1].getJobCounts(); + data.waiting += counts.waiting; + data.active += counts.active; + data.completed += counts.completed; + data.failed += counts.failed; + data.delayed += counts.delayed; + } + return data; + } + protected listeners() { this.queues.score.on('active', (job) => { this.client.util.signale.pending(`${job.id} has become active.`); diff --git a/src/commands/stats.ts b/src/commands/stats.ts index 6454ba3..72f59ea 100644 --- a/src/commands/stats.ts +++ b/src/commands/stats.ts @@ -26,6 +26,7 @@ export default class Stats extends Command { embed.addField('Commands Executed', `${commands.value}`, true); embed.addField('HTTP Requests Served', `${requests.value}`, true); embed.addField('Pages Sent', `${pages.value}`, true); + embed.addField('Jobs Processed', `${(await this.client.queue.jobCounts()).completed}`, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); return message.channel.createMessage({ embed });