This commit is contained in:
Dragon Fire
2021-02-13 16:45:00 -05:00
parent 79f8773bf3
commit 242d11b49e
2 changed files with 5 additions and 4 deletions
+1
View File
@@ -30,6 +30,7 @@ module.exports = class BlacklistCommand extends Command {
} }
run(msg, { type, target }) { run(msg, { type, target }) {
if (this.client.blacklist[type].includes(target)) return msg.say(`🔨 \`${target}\` is already blacklisted.`);
this.client.blacklist[type].push(target); this.client.blacklist[type].push(target);
this.client.exportBlacklist(); this.client.exportBlacklist();
return msg.say(`🔨 Blacklisted ${type} \`${target}\`.`); return msg.say(`🔨 Blacklisted ${type} \`${target}\`.`);
+4 -4
View File
@@ -82,14 +82,14 @@ module.exports = class XiaoClient extends CommandoClient {
exportBlacklist() { exportBlacklist() {
let text = '{\n "guild": [\n '; let text = '{\n "guild": [\n ';
for (const id of this.blacklist.guild) { for (const id of this.blacklist.guild) {
text += `"${id}",`; text += `"${id}",\n`;
} }
text = text.slice(0, -1); text = text.slice(0, -2);
text += '\n ],\n "user": [\n '; text += '\n ],\n "user": [\n ';
for (const id of this.blacklist.user) { for (const id of this.blacklist.user) {
text += `"${id}",`; text += `"${id}",\n`;
} }
text = text.slice(0, -1); text = text.slice(0, -2);
text += '\n ]\n}\n'; text += '\n ]\n}\n';
const buf = Buffer.from(text); const buf = Buffer.from(text);
fs.writeFileSync(path.join(__dirname, '..', 'blacklist.json'), buf, { encoding: 'utf8' }); fs.writeFileSync(path.join(__dirname, '..', 'blacklist.json'), buf, { encoding: 'utf8' });