mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-11 15:57:50 +02:00
Add ability to disable auto-reply commands in bot lists
This commit is contained in:
@@ -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