From 068f680d7cb1afe877192d12a61016348343cd7d Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 15 Oct 2018 20:23:45 +0200 Subject: [PATCH] Added blacklist --- commands/fun/advice.js | 4 ++++ commands/fun/badmeme.js | 4 ++++ commands/fun/clap.js | 4 ++++ commands/fun/dank.js | 4 ++++ commands/fun/despacito.js | 4 ++++ commands/fun/emotesay.js | 4 ++++ commands/fun/face.js | 4 ++++ commands/fun/funfact.js | 4 ++++ commands/fun/randocat.js | 4 ++++ commands/fun/randodog.js | 4 ++++ commands/fun/reddit.js | 4 ++++ commands/fun/say.js | 4 ++++ commands/fun/youtube.js | 4 ++++ commands/images/god.js | 4 ++++ commands/images/human.js | 4 ++++ commands/images/idubbbz.js | 4 ++++ commands/images/idubbbzpaint.js | 4 ++++ commands/images/like.js | 4 ++++ commands/images/ugly.js | 4 ++++ commands/utility/avatar.js | 4 ++++ commands/utility/feedback.js | 4 ++++ commands/utility/help.js | 5 +++++ commands/utility/info.js | 4 ++++ commands/utility/invite.js | 4 ++++ commands/utility/ping.js | 3 +++ commands/utility/server.js | 4 ++++ commands/utility/stats.js | 5 +++++ commands/utility/supportme.js | 4 ++++ commands/utility/updoot.js | 4 ++++ json/blacklist.json | 3 +++ 30 files changed, 120 insertions(+) create mode 100644 json/blacklist.json diff --git a/commands/fun/advice.js b/commands/fun/advice.js index 36007ed..0b4118a 100644 --- a/commands/fun/advice.js +++ b/commands/fun/advice.js @@ -1,6 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch') +const blacklist = require('../../json/blacklist.json') + module.exports = class AdviceCommand extends Command { constructor(client) { super(client, { @@ -12,6 +14,8 @@ module.exports = class AdviceCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") 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 7bc93d0..978b7f4 100644 --- a/commands/fun/badmeme.js +++ b/commands/fun/badmeme.js @@ -1,5 +1,7 @@ const { Command } = require('discord.js-commando'); const fetch = require('node-fetch') +const blacklist = require('../../json/blacklist.json') + module.exports = class BadMemeCommand extends Command { constructor(client) { super(client, { @@ -11,6 +13,8 @@ module.exports = class BadMemeCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") 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 d814469..0fff249 100644 --- a/commands/fun/clap.js +++ b/commands/fun/clap.js @@ -1,4 +1,6 @@ const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class clapCommand extends Command { constructor(client) { super(client, { @@ -17,6 +19,8 @@ module.exports = class clapCommand extends Command { } async run(message, { text }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let clap = text.replace(/ /g, ' 👏 '); message.delete(); message.say(`${clap} 👏`); diff --git a/commands/fun/dank.js b/commands/fun/dank.js index 0c37087..11085e3 100644 --- a/commands/fun/dank.js +++ b/commands/fun/dank.js @@ -1,5 +1,7 @@ const { Command } = require('discord.js-commando'); const responseObject = require("../../json/randVid.json"); +const blacklist = require('../../json/blacklist.json') + module.exports = class dankCommand extends Command { constructor(client) { super(client, { @@ -11,6 +13,8 @@ module.exports = class dankCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") 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 f99174e..52eca71 100644 --- a/commands/fun/despacito.js +++ b/commands/fun/despacito.js @@ -3,6 +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') + module.exports = class DespacitoCommand extends Command { constructor(client) { super(client, { @@ -22,6 +24,8 @@ module.exports = class DespacitoCommand extends Command { } async run(message, { user }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") 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 b93ed93..12b028a 100644 --- a/commands/fun/emotesay.js +++ b/commands/fun/emotesay.js @@ -1,5 +1,7 @@ const { Command } = require('discord.js-commando'); const emojiCharacters = require('../../emojiCharacters'); +const blacklist = require('../../json/blacklist.json') + module.exports = class emoteSayCommand extends Command { constructor(client) { super(client, { @@ -18,6 +20,8 @@ module.exports = class emoteSayCommand extends Command { } async run(message, { text }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") message.delete(); let emojiArray = []; for (let i = 0; i < text.length; i++) diff --git a/commands/fun/face.js b/commands/fun/face.js index 1a793f6..caa4a1b 100644 --- a/commands/fun/face.js +++ b/commands/fun/face.js @@ -1,6 +1,8 @@ const { Command } = require('discord.js-commando'); const faceapp = require('faceapp') const superagent = require('superagent') +const blacklist = require('../../json/blacklist.json') + module.exports = class faceappCommand extends Command { constructor(client) { super(client, { @@ -27,6 +29,8 @@ module.exports = class faceappCommand extends Command { } async run(message, { url, type }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let Attachment = (message.attachments).array(); let origin = null; diff --git a/commands/fun/funfact.js b/commands/fun/funfact.js index 568fa97..a225a41 100644 --- a/commands/fun/funfact.js +++ b/commands/fun/funfact.js @@ -1,5 +1,7 @@ const { Command } = require('discord.js-commando'); const responseObject = require("../../json/funfact.json"); +const blacklist = require('../../json/blacklist.json') + module.exports = class FunFactCommand extends Command { constructor(client) { super(client, { @@ -11,6 +13,8 @@ module.exports = class FunFactCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") 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/randocat.js b/commands/fun/randocat.js index 81ae880..b44ae81 100644 --- a/commands/fun/randocat.js +++ b/commands/fun/randocat.js @@ -1,6 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch') +const blacklist = require('../../json/blacklist.json') + module.exports = class RandoDogCommand extends Command { constructor(client) { super(client, { @@ -12,6 +14,8 @@ module.exports = class RandoDogCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") fetch("http://aws.random.cat/meow").then((response) => { return response.json(); diff --git a/commands/fun/randodog.js b/commands/fun/randodog.js index 408bb40..ae0372d 100644 --- a/commands/fun/randodog.js +++ b/commands/fun/randodog.js @@ -1,6 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch') +const blacklist = require('../../json/blacklist.json') + module.exports = class RandoCatCommand extends Command { constructor(client) { super(client, { @@ -12,6 +14,8 @@ module.exports = class RandoCatCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") fetch("https://random.dog/woof.json").then((response) => { return response.json(); diff --git a/commands/fun/reddit.js b/commands/fun/reddit.js index 18c6ec2..c6173a4 100644 --- a/commands/fun/reddit.js +++ b/commands/fun/reddit.js @@ -1,6 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch'); +const blacklist = require('../../json/blacklist.json') + module.exports = class redditCommand extends Command { constructor(client) { super(client, { @@ -19,6 +21,8 @@ module.exports = class redditCommand extends Command { } async run(message, { sub }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") 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 64e7c97..d3d98e2 100644 --- a/commands/fun/say.js +++ b/commands/fun/say.js @@ -1,4 +1,6 @@ const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class sayCommand extends Command { constructor(client) { super(client, { @@ -17,6 +19,8 @@ module.exports = class sayCommand extends Command { } async run(message, { text }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") message.delete(); message.say(text); } diff --git a/commands/fun/youtube.js b/commands/fun/youtube.js index c8586f7..04d70f1 100644 --- a/commands/fun/youtube.js +++ b/commands/fun/youtube.js @@ -1,6 +1,8 @@ const { Command } = require('discord.js-commando'); const fs = require('fs'); const ytdl = require('ytdl-core') +const blacklist = require('../../json/blacklist.json') + module.exports = class youtubeCommand extends Command { constructor(client) { super(client, { @@ -20,6 +22,8 @@ module.exports = class youtubeCommand extends Command { } async run(message, { link }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") if(link.includes("http") || link.includes("www")) { ytdl(link, { filter: (format) => format.container === 'mp4' }) .pipe(fs.createWriteStream('video.mp4')) diff --git a/commands/images/god.js b/commands/images/god.js index 636e360..695f6f4 100644 --- a/commands/images/god.js +++ b/commands/images/god.js @@ -2,6 +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') + module.exports = class godCommand extends Command { @@ -15,6 +17,8 @@ module.exports = class godCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/human.js b/commands/images/human.js index 212b914..fe70071 100644 --- a/commands/images/human.js +++ b/commands/images/human.js @@ -2,6 +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') + module.exports = class humanCommand extends Command { @@ -15,6 +17,8 @@ module.exports = class humanCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/idubbbz.js b/commands/images/idubbbz.js index 8c7e767..e355125 100644 --- a/commands/images/idubbbz.js +++ b/commands/images/idubbbz.js @@ -2,6 +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') + module.exports = class idubbbzCommand extends Command { @@ -24,6 +26,8 @@ module.exports = class idubbbzCommand extends Command { } async run(message, { text }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/idubbbzpaint.js b/commands/images/idubbbzpaint.js index e6c97e7..9295b88 100644 --- a/commands/images/idubbbzpaint.js +++ b/commands/images/idubbbzpaint.js @@ -2,6 +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') + module.exports = class idubbbzpaintCommand extends Command { @@ -24,6 +26,8 @@ module.exports = class idubbbzpaintCommand extends Command { } async run(message, { text }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/like.js b/commands/images/like.js index 7bb0d7f..ea3b5df 100644 --- a/commands/images/like.js +++ b/commands/images/like.js @@ -2,6 +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') + module.exports = class likeCommand extends Command { @@ -15,6 +17,8 @@ module.exports = class likeCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/images/ugly.js b/commands/images/ugly.js index 0d876eb..e5e39a3 100644 --- a/commands/images/ugly.js +++ b/commands/images/ugly.js @@ -2,6 +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') + module.exports = class uglyCommand extends Command { @@ -15,6 +17,8 @@ module.exports = class uglyCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") let Attachment = (message.attachments).array(); let image = null if (!Attachment[0]) diff --git a/commands/utility/avatar.js b/commands/utility/avatar.js index 68eeeb9..f4ad27e 100644 --- a/commands/utility/avatar.js +++ b/commands/utility/avatar.js @@ -1,4 +1,6 @@ const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class AvatarCommand extends Command { constructor(client) { super(client, { @@ -20,6 +22,8 @@ module.exports = class AvatarCommand extends Command { } async run(message, { user }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") if (!user) return message.say(`Your avatar:\n${message.author.displayAvatarURL}`); else diff --git a/commands/utility/feedback.js b/commands/utility/feedback.js index f0b0d64..b636fc8 100644 --- a/commands/utility/feedback.js +++ b/commands/utility/feedback.js @@ -1,5 +1,7 @@ const { Command } = require('discord.js-commando'); const { feedbackChannel } = require('../../config.json'); +const blacklist = require('../../json/blacklist.json') + const fs = require('fs'); module.exports = class feedbackCommand extends Command { constructor(client) { @@ -23,6 +25,8 @@ module.exports = class feedbackCommand extends Command { } async run(message, { text }) { + if(blacklist[msg.author.id]) + return msg.channel.send("You are blacklisted") const channel = this.client.channels.get(feedbackChannel); channel.send(`from ${message.author.username} (${message.author} : ${message.author.id}): ${text}`); message.say('Your feedback has been sent!'); diff --git a/commands/utility/help.js b/commands/utility/help.js index 735a486..146460e 100644 --- a/commands/utility/help.js +++ b/commands/utility/help.js @@ -1,5 +1,7 @@ const { stripIndents, oneLine } = require('common-tags'); const { Command, disambiguation } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class HelpCommand extends Command { constructor(client) { @@ -27,6 +29,9 @@ module.exports = class HelpCommand extends Command { } async run(msg, args) { // eslint-disable-line complexity + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") + const groups = this.client.registry.groups; const commands = this.client.registry.findCommands(args.command, false, msg); const showAll = args.command && args.command.toLowerCase() === 'all'; diff --git a/commands/utility/info.js b/commands/utility/info.js index 100afff..6df9812 100644 --- a/commands/utility/info.js +++ b/commands/utility/info.js @@ -1,6 +1,8 @@ const { Command } = require('discord.js-commando'); const Discord = require('discord.js'); const fetch = require('node-fetch') +const blacklist = require('../../json/blacklist.json') + module.exports = class InfoCommand extends Command { constructor(client) { super(client, { @@ -19,6 +21,8 @@ module.exports = class InfoCommand extends Command { } async run(message, { search }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") 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 76d32b0..164aa72 100644 --- a/commands/utility/invite.js +++ b/commands/utility/invite.js @@ -1,5 +1,7 @@ const { Command } = require('discord.js-commando'); const { supportServer } = require('../../config.json') +const blacklist = require('../../json/blacklist.json') + module.exports = class InviteCommand extends Command { constructor(client) { super(client, { @@ -11,6 +13,8 @@ module.exports = class InviteCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") return message.say(`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 :)`); } }; \ No newline at end of file diff --git a/commands/utility/ping.js b/commands/utility/ping.js index 4cffe9f..17c71ad 100644 --- a/commands/utility/ping.js +++ b/commands/utility/ping.js @@ -1,5 +1,6 @@ const { oneLine } = require('common-tags'); const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') module.exports = class PingCommand extends Command { constructor(client) { @@ -16,6 +17,8 @@ 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...'); return pingMsg.edit(oneLine` diff --git a/commands/utility/server.js b/commands/utility/server.js index b0693cf..36ea2f6 100644 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -1,4 +1,6 @@ const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class ServerCommand extends Command { constructor(client) { super(client, { @@ -12,6 +14,8 @@ module.exports = class ServerCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") const addEmbed = { color: 0x0099ff, title: 'Stats of the server', diff --git a/commands/utility/stats.js b/commands/utility/stats.js index e1bf211..ca95051 100644 --- a/commands/utility/stats.js +++ b/commands/utility/stats.js @@ -1,4 +1,6 @@ const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class statsCommand extends Command { constructor(client) { super(client, { @@ -10,6 +12,9 @@ module.exports = class statsCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") + return msg.channel.send("You are blacklisted") 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 618b2bd..d6e396c 100644 --- a/commands/utility/supportme.js +++ b/commands/utility/supportme.js @@ -1,4 +1,6 @@ const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class supportMeCommand extends Command { constructor(client) { super(client, { @@ -10,6 +12,8 @@ module.exports = class supportMeCommand extends Command { } async run(message, { text }) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") message.say('If you want to support me and my bot you can donate here\nhttps://donatebot.io/checkout/487640086859743232\n(This is totally optionnal 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 363af43..169991c 100644 --- a/commands/utility/updoot.js +++ b/commands/utility/updoot.js @@ -1,4 +1,6 @@ const { Command } = require('discord.js-commando'); +const blacklist = require('../../json/blacklist.json') + module.exports = class UpDootCommand extends Command { constructor(client) { super(client, { @@ -11,6 +13,8 @@ module.exports = class UpDootCommand extends Command { } async run(message) { + if(blacklist[message.author.id]) + return message.channel.send("You are blacklisted") const upDoot = { color: 0x93C54B, title: 'Vote for my bot', diff --git a/json/blacklist.json b/json/blacklist.json new file mode 100644 index 0000000..e788c9f --- /dev/null +++ b/json/blacklist.json @@ -0,0 +1,3 @@ +{ + "placeholder": "placeholder" +} \ No newline at end of file