diff --git a/src/lib/bot/Bot.ts b/src/lib/bot/Bot.ts index d1d6da47..c5e15ea5 100644 --- a/src/lib/bot/Bot.ts +++ b/src/lib/bot/Bot.ts @@ -328,18 +328,6 @@ export class Bot extends Client this._guildStorageLoader.cleanGuilds(this._guildDataStorage, this._guildSettingStorage); } - /** - * Emitted whenever a command is successfully called - * @memberof Bot - * @instance - * @event event:command - * @param {string} name Name of the called command - * @param {any[]} args Args passed to the called command - * @param {number} execTime Time command took to execute - * @param {external:Message} message Message that triggered the command - */ - public on(event: 'command', listener: (name: string, args: any[], execTime: number, message: Message) => void): this; - //#region Discord.js events public on(event: 'channelCreate', listener: (channel: Channel) => void): this; @@ -383,10 +371,43 @@ export class Bot extends Client public on(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this; public on(event: 'voiceStateUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this; public on(event: 'warn', listener: (info: string) => void): this; + +//#endregion + + public on(event: 'command', listener: (name: string, args: any[], execTime: number, message: Message) => void): this; + public on(event: 'blacklistAdd', listener: (user: User, global: boolean) => void): this; + public on(event: 'blacklistRemove', listener: (user: User, global: boolean) => void): this; + + /** + * Emitted whenever a command is successfully called + * @memberof Bot + * @instance + * @event event:command + * @param {string} name Name of the called command + * @param {any[]} args Args passed to the called command + * @param {number} execTime Time command took to execute + * @param {external:Message} message Message that triggered the command + */ + + /** + * Emitted whenever a user is blacklisted + * @memberof Bot + * @instance + * @event event:blacklistAdd + * @param {User} user User who was blacklisted + * @param {boolean} global Whether or not blacklisting is global + */ + + /** + * Emitted whenever a user is removed from the blacklist + * @memberof Bot + * @instance + * @event event:blacklistRemove + * @param {User} user User who was removed + * @param {boolean} global Whether or not removal is global + */ public on(event: string, listener: Function): this { return super.on(event, listener); } - -//#endregion } diff --git a/src/lib/command/base/blacklist/Blacklist.ts b/src/lib/command/base/blacklist/Blacklist.ts index a01dbc69..d5472381 100644 --- a/src/lib/command/base/blacklist/Blacklist.ts +++ b/src/lib/command/base/blacklist/Blacklist.ts @@ -39,6 +39,7 @@ export default class Blacklist extends Command return message.channel.send('That user is already globally blacklisted.'); this.bot.storage.setItem(`blacklist/${user.id}`, true); + this.bot.emit('blacklistAdd', user, true); return message.channel.send(`Added ${user.username}#${user.discriminator} to the global blacklist.`); } @@ -49,6 +50,7 @@ export default class Blacklist extends Command return message.channel.send('That user is already blacklisted in this server.'); message.guild.storage.setSetting(`blacklist/${user.id}`, true); + this.bot.emit('blacklistAdd', user, false); return message.channel.send(`Added ${user.username}#${user.discriminator} to this server's blacklist.`); } } diff --git a/src/lib/command/base/blacklist/Whitelist.ts b/src/lib/command/base/blacklist/Whitelist.ts index 1b73929c..f3916125 100644 --- a/src/lib/command/base/blacklist/Whitelist.ts +++ b/src/lib/command/base/blacklist/Whitelist.ts @@ -33,6 +33,7 @@ export default class Whitelist extends Command return message.channel.send('That user is not currently globally blacklisted.'); this.bot.storage.removeItem(`blacklist/${user.id}`); + this.bot.emit('blacklistRemove', user, true); return message.channel.send(`Removed ${user.username}#${user.discriminator} from the global blacklist.`); } @@ -40,6 +41,7 @@ export default class Whitelist extends Command return message.channel.send('That user is not currently blacklisted in this server.'); message.guild.storage.removeSetting(`blacklist/${user.id}`); + this.bot.emit('blacklistRemove', user, false); return message.channel.send(`Removed ${user.username}#${user.discriminator} from this server's blacklist.`); } } diff --git a/tsconfig.json b/tsconfig.json index acfd1ed5..92fd66fe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,8 @@ "es7" ], "declaration": true, - "sourceMap": true + "sourceMap": true, + "removeComments": false }, "exclude": [ "node_modules",