Skip to content

Commit

Permalink
Add dummy mode to debug (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNovak authored Feb 1, 2021
1 parent c3a92c0 commit e21d865
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
4 changes: 4 additions & 0 deletions config/debug.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"enabled": false,
"value": 2
}
},
"dummyMode": {
"enabled": false,
"whitelist": ["212772875793334272", "478288246858711040"]
}
}
24 changes: 18 additions & 6 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Job } from './jobs';
import { Logger } from './services';

let Config = require('../config/config.json');
let Debug = require('../config/debug.json');
let Logs = require('../lang/logs.json');

export class Bot {
Expand Down Expand Up @@ -70,8 +71,10 @@ export class Bot {
let userTag = this.client.user.tag;
Logger.info(Logs.info.login.replace('{USER_TAG}', userTag));

this.startJobs();
Logger.info(Logs.info.startedJobs);
if (!Debug.dummyMode.enabled) {
this.startJobs();
Logger.info(Logs.info.startedJobs);
}

this.ready = true;
}
Expand All @@ -81,7 +84,7 @@ export class Bot {
}

private async onGuildJoin(guild: Guild): Promise<void> {
if (!this.ready) {
if (!this.ready || Debug.dummyMode.enabled) {
return;
}

Expand All @@ -93,7 +96,7 @@ export class Bot {
}

private async onGuildLeave(guild: Guild): Promise<void> {
if (!this.ready) {
if (!this.ready || Debug.dummyMode.enabled) {
return;
}

Expand All @@ -105,12 +108,21 @@ export class Bot {
}

private async onReactionAdd(msgReaction: any, reactor: User): Promise<void> {
if (!this.ready) return;
if (
!this.ready ||
(Debug.dummyMode.enabled && !Debug.dummyMode.whitelist.includes(reactor.id))
) {
return;
}

this.reactionAddHandler.process(msgReaction, reactor);
}

private async onMessage(msg: Message): Promise<void> {
if (!this.ready) {
if (
!this.ready ||
(Debug.dummyMode.enabled && !Debug.dummyMode.whitelist.includes(msg.author.id))
) {
return;
}

Expand Down
7 changes: 6 additions & 1 deletion src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { Shard, ShardingManager } from 'discord.js';
import { Logger } from './services';
import { Job } from './jobs';

let Logs = require('../lang/logs.json');
let Config = require('../config/config.json');
let Debug = require('../config/debug.json');
let Logs = require('../lang/logs.json');

export class Manager {
constructor(private shardManager: ShardingManager, private jobs: Job[]) {}
Expand All @@ -28,6 +29,10 @@ export class Manager {
return;
}

if (Debug.dummyMode.enabled) {
return;
}

this.startJobs();
}

Expand Down

0 comments on commit e21d865

Please sign in to comment.