mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Add patronOnly Option
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { stripIndents } = require('common-tags');
|
|
||||||
|
|
||||||
module.exports = class CleverbotEndCommand extends Command {
|
module.exports = class CleverbotEndCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -8,17 +7,12 @@ module.exports = class CleverbotEndCommand extends Command {
|
|||||||
aliases: ['clevs-end', 'chat-end', 'end'],
|
aliases: ['clevs-end', 'chat-end', 'end'],
|
||||||
group: 'cleverbot',
|
group: 'cleverbot',
|
||||||
memberName: 'cleverbot-end',
|
memberName: 'cleverbot-end',
|
||||||
description: 'Ends the current Cleverbot chat.'
|
description: 'Ends the current Cleverbot chat.',
|
||||||
|
patronOnly: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
run(msg) {
|
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);
|
const cleverbot = this.client.cleverbots.get(msg.channel.id);
|
||||||
if (!cleverbot) return msg.say('There is not a Cleverbot conversation in this channel.');
|
if (!cleverbot) return msg.say('There is not a Cleverbot conversation in this channel.');
|
||||||
clearTimeout(cleverbot.timeout);
|
clearTimeout(cleverbot.timeout);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module.exports = class CleverbotCommand extends Command {
|
|||||||
group: 'cleverbot',
|
group: 'cleverbot',
|
||||||
memberName: 'cleverbot',
|
memberName: 'cleverbot',
|
||||||
description: 'Starts a Cleverbot conversation.',
|
description: 'Starts a Cleverbot conversation.',
|
||||||
|
patronOnly: true,
|
||||||
credit: [
|
credit: [
|
||||||
{
|
{
|
||||||
name: 'Cleverbot',
|
name: 'Cleverbot',
|
||||||
@@ -22,12 +23,6 @@ module.exports = class CleverbotCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run(msg) {
|
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)) {
|
if (this.client.cleverbots.has(msg.channel.id)) {
|
||||||
return msg.say('There is already a Cleverbot conversation in this channel.');
|
return msg.say('There is already a Cleverbot conversation in this channel.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { stripIndents } = require('common-tags');
|
||||||
|
|
||||||
module.exports = class XiaoCommand extends Command {
|
module.exports = class XiaoCommand extends Command {
|
||||||
constructor(client, info) {
|
constructor(client, info) {
|
||||||
if (!info.argsPromptLimit) info.argsPromptLimit = 2;
|
if (!info.argsPromptLimit) info.argsPromptLimit = 2;
|
||||||
super(client, info);
|
super(client, info);
|
||||||
|
|
||||||
|
this.patronOnly = info.patronOnly || false;
|
||||||
this.argsSingleQuotes = info.argsSingleQuotes || false;
|
this.argsSingleQuotes = info.argsSingleQuotes || false;
|
||||||
this.throttling = info.unknown ? null : info.throttling || { usages: 2, duration: 5 };
|
this.throttling = info.unknown ? null : info.throttling || { usages: 2, duration: 5 };
|
||||||
this.uses = 0;
|
this.uses = 0;
|
||||||
@@ -16,4 +18,14 @@ module.exports = class XiaoCommand extends Command {
|
|||||||
reason: 'Code'
|
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