From c97a9d4ad44a8324cebddcf2e78ecda4a1a7c1c9 Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Wed, 28 Nov 2018 01:05:55 +0100 Subject: [PATCH] updated how blacklist work --- commands/fun/advice.js | 9 ++++++--- commands/fun/badmeme.js | 8 +++++--- commands/fun/clap.js | 10 ++++++---- commands/fun/dank.js | 10 ++++++---- commands/fun/despacito.js | 10 ++++++---- commands/fun/emotesay.js | 10 ++++++---- commands/fun/funfact.js | 10 ++++++---- commands/fun/ib.js | 8 +++++--- commands/fun/print.js | 12 +++++------- commands/fun/reddit.js | 10 ++++++---- commands/fun/say.js | 10 ++++++---- commands/images/face.js | 8 +++++--- commands/images/fetish.js | 10 ++++++---- commands/images/god.js | 10 ++++++---- commands/images/human.js | 10 ++++++---- commands/images/idubbbz.js | 10 ++++++---- commands/images/idubbbzpaint.js | 10 ++++++---- commands/images/like.js | 10 ++++++---- commands/images/ugly.js | 10 ++++++---- commands/utility/avatar.js | 9 ++++++--- commands/utility/download.js | 9 ++++++--- commands/utility/feedback.js | 10 ++++++---- commands/utility/info.js | 10 ++++++---- commands/utility/invite.js | 10 ++++++---- commands/utility/ping.js | 26 ++++++++++++++------------ commands/utility/server.js | 10 ++++++---- commands/utility/stats.js | 10 ++++++---- commands/utility/supportme.js | 10 ++++++---- commands/utility/updoot.js | 10 ++++++---- index.js | 2 +- 30 files changed, 179 insertions(+), 122 deletions(-) diff --git a/commands/fun/advice.js b/commands/fun/advice.js index 0b4118a0..8533bede 100644 --- a/commands/fun/advice.js +++ b/commands/fun/advice.js @@ -1,7 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch') -const blacklist = require('../../json/blacklist.json') +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class AdviceCommand extends Command { constructor(client) { @@ -14,8 +15,10 @@ module.exports = class AdviceCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + fetch("http://api.adviceslip.com/advice").then((response) => { return response.json(); }).then((response) => { diff --git a/commands/fun/badmeme.js b/commands/fun/badmeme.js index 978b7f4c..d79587e3 100644 --- a/commands/fun/badmeme.js +++ b/commands/fun/badmeme.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const fetch = require('node-fetch') -const blacklist = require('../../json/blacklist.json') +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class BadMemeCommand extends Command { constructor(client) { @@ -13,8 +14,9 @@ module.exports = class BadMemeCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) fetch("https://api.imgur.com/3/gallery/hot/day?showViral=true&mature=false&perPage=100&album_previews=true", { headers: { "Authorization": "Client-ID e4cb6948f80f295" }, diff --git a/commands/fun/clap.js b/commands/fun/clap.js index 0fff2499..162a2a21 100644 --- a/commands/fun/clap.js +++ b/commands/fun/clap.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class clapCommand extends Command { constructor(client) { super(client, { @@ -19,8 +19,10 @@ module.exports = class clapCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let clap = text.replace(/ /g, ' 👏 '); message.delete(); message.say(`${clap} 👏`); diff --git a/commands/fun/dank.js b/commands/fun/dank.js index 11085e36..9d068c90 100644 --- a/commands/fun/dank.js +++ b/commands/fun/dank.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const responseObject = require("../../json/randVid.json"); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class dankCommand extends Command { constructor(client) { super(client, { @@ -13,8 +13,10 @@ module.exports = class dankCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + const number = Object.keys(responseObject).length; const vidNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1; message.channel.send(`${vidNumber}: ${responseObject[vidNumber]}`); diff --git a/commands/fun/despacito.js b/commands/fun/despacito.js index 1c909a27..24e27056 100644 --- a/commands/fun/despacito.js +++ b/commands/fun/despacito.js @@ -3,8 +3,8 @@ const responseObject = require("../../json/despacito.json"); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') const Discord = require('discord.js'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class DespacitoCommand extends Command { constructor(client) { super(client, { @@ -24,8 +24,10 @@ module.exports = class DespacitoCommand extends Command { } async run(message, { user }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + if (!user) { const number = Object.keys(responseObject).length; const despacitoNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1; diff --git a/commands/fun/emotesay.js b/commands/fun/emotesay.js index 12b028a4..0fe97665 100644 --- a/commands/fun/emotesay.js +++ b/commands/fun/emotesay.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const emojiCharacters = require('../../emojiCharacters'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class emoteSayCommand extends Command { constructor(client) { super(client, { @@ -20,8 +20,10 @@ module.exports = class emoteSayCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + message.delete(); let emojiArray = []; for (let i = 0; i < text.length; i++) diff --git a/commands/fun/funfact.js b/commands/fun/funfact.js index a225a416..a5306ea4 100644 --- a/commands/fun/funfact.js +++ b/commands/fun/funfact.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const responseObject = require("../../json/funfact.json"); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class FunFactCommand extends Command { constructor(client) { super(client, { @@ -13,8 +13,10 @@ module.exports = class FunFactCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + const number = Object.keys(responseObject).length; const funFactNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1; message.channel.send(`Fun fact: ${responseObject[funFactNumber]}`); diff --git a/commands/fun/ib.js b/commands/fun/ib.js index 3a241023..768c09b8 100644 --- a/commands/fun/ib.js +++ b/commands/fun/ib.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const fetch = require('node-fetch') -const blacklist = require('../../json/blacklist.json') +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class BadMemeCommand extends Command { constructor(client) { @@ -14,8 +15,9 @@ module.exports = class BadMemeCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) fetch('http://inspirobot.me/api?generate=true') .then(res => res.text()) diff --git a/commands/fun/print.js b/commands/fun/print.js index c69672d4..3078b0ac 100644 --- a/commands/fun/print.js +++ b/commands/fun/print.js @@ -1,8 +1,8 @@ const { Command } = require('discord.js-commando'); const printer = require('printer'); const { printChannel } = require('../../config.json'); -const blacklist = require('../../json/blacklist.json'); -module.exports = class printCommand extends Command { +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist');module.exports = class printCommand extends Command { constructor(client) { super(client, { name: 'print', @@ -25,13 +25,11 @@ module.exports = class printCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") - + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) const channel = this.client.channels.get(printChannel); - - printer.printDirect({data:`Printed by: ${message.author.username}\n\n${text}` , type: 'TEXT' // type: RAW, TEXT, PDF, JPEG, .. depends on platform , success:function(jobID){ diff --git a/commands/fun/reddit.js b/commands/fun/reddit.js index c6173a44..9b58527a 100644 --- a/commands/fun/reddit.js +++ b/commands/fun/reddit.js @@ -1,8 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class redditCommand extends Command { constructor(client) { super(client, { @@ -21,8 +21,10 @@ module.exports = class redditCommand extends Command { } async run(message, { sub }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let /* the bodies hit the */ i = Math.floor((Math.random() * 10) + 1); let a = 0 fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => { diff --git a/commands/fun/say.js b/commands/fun/say.js index d3d98e28..01e59604 100644 --- a/commands/fun/say.js +++ b/commands/fun/say.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class sayCommand extends Command { constructor(client) { super(client, { @@ -19,8 +19,10 @@ module.exports = class sayCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + message.delete(); message.say(text); } diff --git a/commands/images/face.js b/commands/images/face.js index a9e879b0..e8cbc14f 100644 --- a/commands/images/face.js +++ b/commands/images/face.js @@ -1,7 +1,8 @@ const { Command } = require('discord.js-commando'); const faceapp = require('faceapp') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class faceappCommand extends Command { constructor(client) { @@ -29,8 +30,9 @@ module.exports = class faceappCommand extends Command { } async run(message, { url, type }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) let Attachment = (message.attachments).array(); let origin = null; diff --git a/commands/images/fetish.js b/commands/images/fetish.js index 20267b4d..e250e373 100644 --- a/commands/images/fetish.js +++ b/commands/images/fetish.js @@ -2,8 +2,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class fetishCommand extends Command { @@ -17,8 +17,10 @@ module.exports = class fetishCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/god.js b/commands/images/god.js index 1b92dfbc..0bbcf359 100644 --- a/commands/images/god.js +++ b/commands/images/god.js @@ -2,8 +2,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class godCommand extends Command { @@ -17,8 +17,10 @@ module.exports = class godCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/human.js b/commands/images/human.js index 579cdb5f..e7350eec 100644 --- a/commands/images/human.js +++ b/commands/images/human.js @@ -2,8 +2,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class humanCommand extends Command { @@ -17,8 +17,10 @@ module.exports = class humanCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/idubbbz.js b/commands/images/idubbbz.js index 358f225f..47f21bd4 100644 --- a/commands/images/idubbbz.js +++ b/commands/images/idubbbz.js @@ -2,8 +2,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class idubbbzCommand extends Command { @@ -26,8 +26,10 @@ module.exports = class idubbbzCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/idubbbzpaint.js b/commands/images/idubbbzpaint.js index a3b75f94..54c5f00a 100644 --- a/commands/images/idubbbzpaint.js +++ b/commands/images/idubbbzpaint.js @@ -2,8 +2,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class idubbbzpaintCommand extends Command { @@ -26,8 +26,10 @@ module.exports = class idubbbzpaintCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/like.js b/commands/images/like.js index b73f923b..aee5adc7 100644 --- a/commands/images/like.js +++ b/commands/images/like.js @@ -2,8 +2,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class likeCommand extends Command { @@ -17,8 +17,10 @@ module.exports = class likeCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/ugly.js b/commands/images/ugly.js index 0bbf8669..3bdb4cb7 100644 --- a/commands/images/ugly.js +++ b/commands/images/ugly.js @@ -2,8 +2,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const { createCanvas, loadImage, getContext } = require('canvas') const superagent = require('superagent') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class uglyCommand extends Command { @@ -17,8 +17,10 @@ module.exports = class uglyCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/utility/avatar.js b/commands/utility/avatar.js index 44b87aad..28dc0a0a 100644 --- a/commands/utility/avatar.js +++ b/commands/utility/avatar.js @@ -1,5 +1,6 @@ const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class AvatarCommand extends Command { constructor(client) { @@ -20,8 +21,10 @@ module.exports = class AvatarCommand extends Command { } async run(message, { user }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + if (!user) return message.say(`Your avatar:\n${message.author.displayAvatarURL}`); else diff --git a/commands/utility/download.js b/commands/utility/download.js index 2e1e6017..15e3e3a6 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -1,7 +1,8 @@ const { Command } = require('discord.js-commando'); const fs = require('fs'); const youtubedl = require('youtube-dl'); -const blacklist = require('../../json/blacklist.json'); +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); const { fbuser, fbpasswd } = require('../../config.json'); module.exports = class downloadCommand extends Command { @@ -23,8 +24,10 @@ module.exports = class downloadCommand extends Command { } async run(message, { link }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + if(link.includes("http") || link.includes("www")) { message.say('Downloading...').then(msg => { video.on('end', function() { diff --git a/commands/utility/feedback.js b/commands/utility/feedback.js index 7ed77134..570ef07d 100644 --- a/commands/utility/feedback.js +++ b/commands/utility/feedback.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const { feedbackChannel } = require('../../config.json'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); const fs = require('fs'); module.exports = class feedbackCommand extends Command { constructor(client) { @@ -25,8 +25,10 @@ module.exports = class feedbackCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + const channel = this.client.channels.get(feedbackChannel); channel.send(`from ${message.author.username} (${message.author.id}) : ${text}`); message.say('Your feedback has been sent!'); diff --git a/commands/utility/info.js b/commands/utility/info.js index 6df9812e..a9f44cc6 100644 --- a/commands/utility/info.js +++ b/commands/utility/info.js @@ -1,8 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class InfoCommand extends Command { constructor(client) { super(client, { @@ -21,8 +21,10 @@ module.exports = class InfoCommand extends Command { } async run(message, { search }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let searchURL = encodeURI(search) fetch("https://api.duckduckgo.com/?q=" + searchURL + "&format=json").then((response) => { return response.json(); diff --git a/commands/utility/invite.js b/commands/utility/invite.js index f24314ed..47cd3f31 100644 --- a/commands/utility/invite.js +++ b/commands/utility/invite.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const { supportServer } = require('../../config.json') -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class InviteCommand extends Command { constructor(client) { super(client, { @@ -13,8 +13,10 @@ module.exports = class InviteCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + message.say('Check your dm') return message.author.send(`You can add me from here: https://discordapp.com/oauth2/authorize?client_id=${this.client.user.id}&scope=bot&permissions=0\nYou can also join my support server over here: ${supportServer} come and say hi :)`); } diff --git a/commands/utility/ping.js b/commands/utility/ping.js index 17c71ad3..b3b5cf1c 100644 --- a/commands/utility/ping.js +++ b/commands/utility/ping.js @@ -1,7 +1,7 @@ const { oneLine } = require('common-tags'); const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class PingCommand extends Command { constructor(client) { super(client, { @@ -16,20 +16,22 @@ module.exports = class PingCommand extends Command { }); } - async run(msg) { - if(blacklist[msg.author.id]) - return msg.channel.send("You are blacklisted") - if(!msg.editable) { - const pingMsg = await msg.say('Pinging...'); + async run(message) { + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + + if(!message.editable) { + const pingMsg = await message.say('Pinging...'); return pingMsg.edit(oneLine` - ${msg.channel.type !== 'dm' ? `${msg.author},` : ''} - <:ping:499226870047571978> Pong! The message round-trip took **${pingMsg.createdTimestamp - msg.createdTimestamp}**ms. + ${message.channel.type !== 'dm' ? `${message.author},` : ''} + <:ping:499226870047571978> Pong! The message round-trip took **${pingMsg.createdTimestamp - message.createdTimestamp}**ms. ${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''} `); } else { - await msg.edit('Pinging...'); - return msg.edit(oneLine` - Pong! The message round-trip took **${msg.editedTimestamp - msg.createdTimestamp}**ms. + await message.edit('Pinging...'); + return message.edit(oneLine` + Pong! The message round-trip took **${message.editedTimestamp - message.createdTimestamp}**ms. ${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''} `); } diff --git a/commands/utility/server.js b/commands/utility/server.js index 36ea2f63..ad7959c3 100644 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class ServerCommand extends Command { constructor(client) { super(client, { @@ -14,8 +14,10 @@ module.exports = class ServerCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + const addEmbed = { color: 0x0099ff, title: 'Stats of the server', diff --git a/commands/utility/stats.js b/commands/utility/stats.js index 5308bcb9..29f31adc 100644 --- a/commands/utility/stats.js +++ b/commands/utility/stats.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class statsCommand extends Command { constructor(client) { super(client, { @@ -12,8 +12,10 @@ module.exports = class statsCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + let totalSeconds = (this.client.uptime / 1000); let days = Math.floor(totalSeconds / 86400); let hours = Math.floor(totalSeconds / 3600); diff --git a/commands/utility/supportme.js b/commands/utility/supportme.js index b288e5ae..4a4e67b4 100644 --- a/commands/utility/supportme.js +++ b/commands/utility/supportme.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class supportMeCommand extends Command { constructor(client) { super(client, { @@ -12,8 +12,10 @@ module.exports = class supportMeCommand extends Command { } async run(message, { text }) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + message.say('If you want to support me and my bot you can donate here\nhttps://donatebot.io/checkout/487640086859743232\n(This is totally optional dont feel forced to do it)'); } }; \ No newline at end of file diff --git a/commands/utility/updoot.js b/commands/utility/updoot.js index 169991c8..d5b76b8d 100644 --- a/commands/utility/updoot.js +++ b/commands/utility/updoot.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); -const blacklist = require('../../json/blacklist.json') - +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); module.exports = class UpDootCommand extends Command { constructor(client) { super(client, { @@ -13,8 +13,10 @@ module.exports = class UpDootCommand extends Command { } async run(message) { - if(blacklist[message.author.id]) - return message.channel.send("You are blacklisted") + let blacklistJson = new SelfReloadJSON('../../json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + const upDoot = { color: 0x93C54B, title: 'Vote for my bot', diff --git a/index.js b/index.js index 0b67983a..3a2452d6 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ const { token, prefix, statsChannel, ownerID, supportServer } = require('./confi const responseObject = require("./json/reply.json"); const reactObject = require("./json/react.json"); const imgResponseObject = require("./json/imgreply.json"); -var SelfReloadJSON = require('self-reload-json'); +const SelfReloadJSON = require('self-reload-json'); // Prefix and ownerID and invite to support server const client = new CommandoClient({ commandPrefix: prefix,