diff --git a/Xiao.js b/Xiao.js index fa21f88e..f384c9c0 100644 --- a/Xiao.js +++ b/Xiao.js @@ -74,6 +74,7 @@ client.on('message', async msg => { client.on('guildMemberRemove', async member => { if (member.id === client.user.id) return null; + if (client.botListGuilds.includes(member.guild.id)) return null; const channel = member.guild.systemChannel; if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return null; if (channel.topic && channel.topic.includes('')) return null; diff --git a/commands/auto/can-you-not.js b/commands/auto/can-you-not.js index 3035155d..6d9b9a66 100644 --- a/commands/auto/can-you-not.js +++ b/commands/auto/can-you-not.js @@ -1,4 +1,4 @@ -const Command = require('../../structures/Command'); +const Command = require('../../structures/commands/AutoReply'); module.exports = class CanYouNotCommand extends Command { constructor(client) { @@ -8,11 +8,12 @@ module.exports = class CanYouNotCommand extends Command { group: 'auto', memberName: 'can-you-not', description: 'Can YOU not?', - patterns: [/can (you|u) not/i] + patterns: [/can (you|u) not/i], + reply: true }); } - run(msg) { - return msg.reply('Can YOU not?'); + generateText() { + return 'Can YOU not?'; } }; diff --git a/commands/auto/kazuma-kazuma.js b/commands/auto/kazuma-kazuma.js index 9ddd3427..3df49cad 100644 --- a/commands/auto/kazuma-kazuma.js +++ b/commands/auto/kazuma-kazuma.js @@ -1,4 +1,4 @@ -const Command = require('../../structures/Command'); +const Command = require('../../structures/commands/AutoReply'); module.exports = class KazumaKazumaCommand extends Command { constructor(client) { @@ -18,7 +18,7 @@ module.exports = class KazumaKazumaCommand extends Command { }); } - run(msg) { - return msg.say('Hai, Kazuma desu.'); + generateText() { + return 'Hai, Kazuma desu.'; } }; diff --git a/commands/auto/no-u.js b/commands/auto/no-u.js index 3d9b1609..fd2a9154 100644 --- a/commands/auto/no-u.js +++ b/commands/auto/no-u.js @@ -1,4 +1,4 @@ -const Command = require('../../structures/Command'); +const Command = require('../../structures/commands/AutoReply'); module.exports = class NoUCommand extends Command { constructor(client) { @@ -12,7 +12,7 @@ module.exports = class NoUCommand extends Command { }); } - run(msg) { - return msg.say('no u'); + generateText() { + return 'no u'; } }; diff --git a/commands/auto/suicide-hotline.js b/commands/auto/suicide-hotline.js index 9feadd5f..142528c0 100644 --- a/commands/auto/suicide-hotline.js +++ b/commands/auto/suicide-hotline.js @@ -1,4 +1,4 @@ -const Command = require('../../structures/Command'); +const Command = require('../../structures/commands/AutoReply'); module.exports = class SuicideHotlineCommand extends Command { constructor(client) { @@ -9,6 +9,7 @@ module.exports = class SuicideHotlineCommand extends Command { memberName: 'suicide-hotline', description: 'Responds with the phone number for the Suicide Hotline.', patterns: [/\bkms\b/i, /\b(kill myself)\b/i, /<:kms:(.+)>/i], + reply: true, credit: [ { name: 'National Suicide Prevention Lifeline', @@ -19,9 +20,9 @@ module.exports = class SuicideHotlineCommand extends Command { }); } - run(msg, args, fromPattern) { + generateText(fromPattern) { const text = 'Call 1-800-273-8255 for the National Suicide Prevention Lifeline.'; - if (!fromPattern) return msg.say(text); - return msg.reply(`Don't say that. Get help. ${text}`); + if (!fromPattern) text; + return `Don't say that. Get help. ${text}`; } }; diff --git a/commands/auto/unflip.js b/commands/auto/unflip.js index d26ee731..bd5a6853 100644 --- a/commands/auto/unflip.js +++ b/commands/auto/unflip.js @@ -1,4 +1,4 @@ -const Command = require('../../structures/Command'); +const Command = require('../../structures/commands/AutoReply'); module.exports = class UnflipCommand extends Command { constructor(client) { @@ -11,7 +11,7 @@ module.exports = class UnflipCommand extends Command { }); } - run(msg) { - return msg.say('┬─┬ ノ( ゜-゜ノ)'); + generateText() { + return '┬─┬ ノ( ゜-゜ノ)'; } }; diff --git a/commands/other/cleverbot.js b/commands/other/cleverbot.js index 1108b68f..d73f0416 100644 --- a/commands/other/cleverbot.js +++ b/commands/other/cleverbot.js @@ -35,7 +35,10 @@ module.exports = class CleverbotCommand extends Command { } async run(msg, { text }, fromPattern) { - if (fromPattern) text = msg.patternMatches[2]; + if (fromPattern) { + if (this.client.botListGuilds.includes(msg.guild.id)) return null; + text = msg.patternMatches[2]; + } try { const convo = this.convos.get(msg.channel.id); const { body } = await request diff --git a/commands/util/unknown-command.js b/commands/util/unknown-command.js index 7b6d67f2..321dcea8 100644 --- a/commands/util/unknown-command.js +++ b/commands/util/unknown-command.js @@ -17,6 +17,7 @@ module.exports = class UnknownCommandCommand extends Command { run(msg) { if (msg.channel.type !== 'text') return null; + if (this.client.botListGuilds.includes(msg.guild.id)) return null; const commands = this.makeCommandArray(this.client.isOwner(msg.author), msg.channel.nsfw); const command = msg.content.match(this.client.dispatcher._commandPatterns[this.client.commandPrefix]); const str = command ? command[2] : msg.content.split(' ')[0]; diff --git a/package.json b/package.json index fc9d2e57..9fd9700a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "112.20.1", + "version": "112.20.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/Client.js b/structures/Client.js index 27f10356..ca4d634a 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -4,12 +4,13 @@ const Collection = require('@discordjs/collection'); const winston = require('winston'); const PokemonStore = require('./pokemon/PokemonStore'); const MemePoster = require('./MemePoster'); -const { XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN } = process.env; +const { XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN, BOT_LIST_GUILDS } = process.env; module.exports = class XiaoClient extends CommandoClient { constructor(options) { super(options); + this.botListGuilds = BOT_LIST_GUILDS ? BOT_LIST_GUILDS.split(',') : []; this.logger = winston.createLogger({ transports: [new winston.transports.Console()], format: winston.format.combine( diff --git a/structures/commands/AutoReply.js b/structures/commands/AutoReply.js new file mode 100644 index 00000000..752d04c1 --- /dev/null +++ b/structures/commands/AutoReply.js @@ -0,0 +1,18 @@ +const Command = require('../Command'); + +module.exports = class AutoReplyCommand extends Command { + constructor(client, info) { + super(client, info); + + this.reply = info.reply || false; + } + + run(msg, args, fromPattern) { + if (this.client.botListGuilds.includes(msg.guild.id)) return null; + return this.reply ? msg.reply(this.generateText(fromPattern)) : msg.say(this.generateText(fromPattern)); + } + + generateText() { + throw new Error('The generateText method is required.'); + } +}; diff --git a/structures/commands/Subreddit.js b/structures/commands/Subreddit.js index 4b50e07c..e10ca4d1 100644 --- a/structures/commands/Subreddit.js +++ b/structures/commands/Subreddit.js @@ -17,7 +17,10 @@ module.exports = class SubredditCommand extends Command { } async run(msg, { subreddit }, fromPattern) { - if (fromPattern) subreddit = msg.patternMatches[1]; + if (fromPattern) { + if (this.client.botListGuilds.includes(msg.guild.id)) return null; + subreddit = msg.patternMatches[1]; + } if (!subreddit) subreddit = typeof this.subreddit === 'function' ? this.subreddit() : this.subreddit; try { const post = await this.random(subreddit, msg.channel.nsfw);