From 45d38ff5b32fdc62031f4c64224b4da9780b986c Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 18 May 2021 20:14:25 -0400 Subject: [PATCH] Add patronOnly Option --- commands/cleverbot/cleverbot-end.js | 10 ++-------- commands/cleverbot/cleverbot.js | 7 +------ structures/Command.js | 12 ++++++++++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/commands/cleverbot/cleverbot-end.js b/commands/cleverbot/cleverbot-end.js index 1db5bc07..04110cdc 100644 --- a/commands/cleverbot/cleverbot-end.js +++ b/commands/cleverbot/cleverbot-end.js @@ -1,5 +1,4 @@ const Command = require('../../structures/Command'); -const { stripIndents } = require('common-tags'); module.exports = class CleverbotEndCommand extends Command { constructor(client) { @@ -8,17 +7,12 @@ module.exports = class CleverbotEndCommand extends Command { aliases: ['clevs-end', 'chat-end', 'end'], group: 'cleverbot', memberName: 'cleverbot-end', - description: 'Ends the current Cleverbot chat.' + description: 'Ends the current Cleverbot chat.', + patronOnly: true }); } run(msg) { - if (!this.client.isOwner(msg.author) && !this.client.patreon.isPatron(msg.author.id)) { - return msg.say(stripIndents` - You are not currently allowed to use Cleverbot. - Please visit ${this.client.options.invite} for more information. - `); - } const cleverbot = this.client.cleverbots.get(msg.channel.id); if (!cleverbot) return msg.say('There is not a Cleverbot conversation in this channel.'); clearTimeout(cleverbot.timeout); diff --git a/commands/cleverbot/cleverbot.js b/commands/cleverbot/cleverbot.js index 8a79e7ac..5456bbd3 100644 --- a/commands/cleverbot/cleverbot.js +++ b/commands/cleverbot/cleverbot.js @@ -10,6 +10,7 @@ module.exports = class CleverbotCommand extends Command { group: 'cleverbot', memberName: 'cleverbot', description: 'Starts a Cleverbot conversation.', + patronOnly: true, credit: [ { name: 'Cleverbot', @@ -22,12 +23,6 @@ module.exports = class CleverbotCommand extends Command { } run(msg) { - if (!this.client.isOwner(msg.author) && !this.client.patreon.isPatron(msg.author.id)) { - return msg.say(stripIndents` - You are not currently allowed to use Cleverbot. - Please visit ${this.client.options.invite} for more information. - `); - } if (this.client.cleverbots.has(msg.channel.id)) { return msg.say('There is already a Cleverbot conversation in this channel.'); } diff --git a/structures/Command.js b/structures/Command.js index 20481022..4bc509a7 100644 --- a/structures/Command.js +++ b/structures/Command.js @@ -1,10 +1,12 @@ const { Command } = require('discord.js-commando'); +const { stripIndents } = require('common-tags'); module.exports = class XiaoCommand extends Command { constructor(client, info) { if (!info.argsPromptLimit) info.argsPromptLimit = 2; super(client, info); + this.patronOnly = info.patronOnly || false; this.argsSingleQuotes = info.argsSingleQuotes || false; this.throttling = info.unknown ? null : info.throttling || { usages: 2, duration: 5 }; this.uses = 0; @@ -16,4 +18,14 @@ module.exports = class XiaoCommand extends Command { reason: 'Code' }); } + + hasPermission(msg) { + if (this.patronOnly && !this.client.patreon.isPatron(msg.author.id)) { + return stripIndents` + The \`${this.name}\` command can only be used by Patrons. + Visit to sign-up! + `; + } + return true; + } };