mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add patronOnly Option
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
@@ -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 <https://www.patreon.com/xiaodiscord> to sign-up!
|
||||
`;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user