From b87435bc986d9fb54d40d05950d51e372a26a2a6 Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Sun, 30 Dec 2018 02:14:43 +0100 Subject: [PATCH] fixed some bug --- commands/admin/prune.js | 4 ++-- commands/admin/untag.js | 2 +- commands/general/ttsvc.js | 4 ++-- commands/utility/taglist.js | 3 +++ listeners/message.js | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/commands/admin/prune.js b/commands/admin/prune.js index dec1025e..7ffe7a71 100644 --- a/commands/admin/prune.js +++ b/commands/admin/prune.js @@ -3,7 +3,7 @@ const { Command } = require('discord-akairo'); class PruneCommand extends Command { constructor() { super('Prune', { - aliases: ['Prune'], + aliases: ['Prune', 'clean', 'purge'], category: 'admin', args: [ { @@ -23,7 +23,7 @@ class PruneCommand extends Command { } async exec(message,args) { - if (args.amount > 99) return; + if (args.amount >= 100) return; message.channel.bulkDelete(args.amount + 1, true); } } diff --git a/commands/admin/untag.js b/commands/admin/untag.js index dfcf9fad..d2be14d0 100644 --- a/commands/admin/untag.js +++ b/commands/admin/untag.js @@ -44,7 +44,7 @@ class UnTagCommand extends Command { } })}}); - return message.say(`The following autoresponse have been deleted: ${trigger}`); + return message.channel.send(`The following autoresponse have been deleted: ${trigger}`); } } diff --git a/commands/general/ttsvc.js b/commands/general/ttsvc.js index e36247ae..84b85813 100644 --- a/commands/general/ttsvc.js +++ b/commands/general/ttsvc.js @@ -43,7 +43,7 @@ class TtsvcCommand extends Command { fs.writeFile('ttsvc.mp3', response.audioContent, 'binary', err => { if (err) { console.error('ERROR:', err); - message.say('An error has occured, the message is probably too long') + message.channel.send('An error has occured, the message is probably too long') return; } console.log('Audio content written to file: ttsvc.mp3'); @@ -57,7 +57,7 @@ class TtsvcCommand extends Command { // If user say "stop" make the bot leave voice channel if (text == 'stop') { voiceChannel.leave(); - message.say('I leaved the channel'); + message.channel.send('I leaved the channel'); } else voiceChannel.join().then(connection => { const dispatcher = connection.playStream('./ttsvc.mp3'); diff --git a/commands/utility/taglist.js b/commands/utility/taglist.js index 03059e3c..89c55c15 100644 --- a/commands/utility/taglist.js +++ b/commands/utility/taglist.js @@ -1,4 +1,7 @@ const { Command } = require('discord-akairo'); +const Discord = require('discord.js'); +const SelfReloadJSON = require('self-reload-json'); +const fs = require('fs'); class taglistCommand extends Command { constructor() { diff --git a/listeners/message.js b/listeners/message.js index c58a0de6..0f660266 100644 --- a/listeners/message.js +++ b/listeners/message.js @@ -2,6 +2,7 @@ const { Listener } = require('discord-akairo'); const responseObject = require("../json/reply.json"); const reactObject = require("../json/react.json"); const imgResponseObject = require("../json/imgreply.json"); +const SelfReloadJSON = require('self-reload-json'); class MessageListener extends Listener { constructor() { @@ -12,8 +13,7 @@ class MessageListener extends Listener { } async exec(message) { - const autoresponse = require("../json/autoresponse.json"); - + let autoresponse = new SelfReloadJSON('./json/autoresponse.json'); let message_content = message.content.toLowerCase(); if (message.author.bot) return; { @@ -39,7 +39,7 @@ class MessageListener extends Listener { message.react("496028845967802378") } } - const customresponse = require(`../tag/${message.guild.id}.json`); + let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`); // User autoresponse if(customresponse[message_content]) { message.channel.send(customresponse[message_content])