mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add ability to disable auto-reply commands in bot lists
This commit is contained in:
@@ -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('<xiao:disable-leave>')) return null;
|
||||
|
||||
@@ -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?';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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.';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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 '┬─┬ ノ( ゜-゜ノ)';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "112.20.1",
|
||||
"version": "112.20.2",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user