From ad5ed9cf2c6a473a130cc13453e14f61ab465b16 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 12 Aug 2019 08:28:04 +0200 Subject: [PATCH 01/25] if message come from nsfw channel, add spoiler --- event/listeners/messageReactionAdd.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index 5ce3d6d..1725f33 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -59,17 +59,27 @@ class MessageReactionAddListener extends Listener { channel = client.channels.get(shameboardChannel['shameboard']); } - const Embed = new MessageEmbed() + let Embed = new MessageEmbed() .setColor(reaction.message.member.displayHexColor) .setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL()) - .setDescription(messageContent) .addField('Jump to', `[message](https://discordapp.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id})`, true) .addField('Channel', reaction.message.channel, true) .setFooter(reaction.count + ' ' + emote) .setTimestamp(); - return channel.send({files: messageAttachments, embed: Embed}) - .catch(() => channel.send(messageAttachments, { embed: Embed})); + if (reaction.message.channel.nsfw) { + Embed.setDescription(`||${messageContent}||`); + if (messageAttachments != '') { + return channel.send(`||${messageAttachments}||`, {embed: Embed}); + } + else { + return channel.send({embed: Embed}); + } + } else { + Embed.setDescription(messageContent); + return channel.send({files: messageAttachments, embed: Embed}) + .catch(() => channel.send(messageAttachments, { embed: Embed})); + } } } } From f6318d274a24da80dd4feb7219714ce8be0ae081 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 29 Jul 2019 23:35:31 +0200 Subject: [PATCH 02/25] check for nolight.png --- commands/images/nolight.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/images/nolight.js b/commands/images/nolight.js index 2d9b82c..290fa25 100644 --- a/commands/images/nolight.js +++ b/commands/images/nolight.js @@ -49,9 +49,11 @@ class nolightCommand extends Command { }); async function apng() { - fs.unlink('./img/nolight.png', (err) => { - if (err) throw err; - }); + if (fs.readFileSync('./img/nolight.png')) { + fs.unlink('./img/nolight.png', (err) => { + if (err) throw err; + }); + } const { stdout, stderr } = await exec('apngasm -o img/nolight.png img/frame00*.png -s') .then(() => message.channel.send({files: ['./img/nolight.png']})); console.log(`stdout: ${stdout}`); From 658bcaf1f8ee77997129e51a942b93cc836fdb77 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 29 Jul 2019 23:36:21 +0200 Subject: [PATCH 03/25] actually its existSync --- commands/images/nolight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/images/nolight.js b/commands/images/nolight.js index 290fa25..f5ef6fe 100644 --- a/commands/images/nolight.js +++ b/commands/images/nolight.js @@ -49,7 +49,7 @@ class nolightCommand extends Command { }); async function apng() { - if (fs.readFileSync('./img/nolight.png')) { + if (fs.existsSync('./img/nolight.png')) { fs.unlink('./img/nolight.png', (err) => { if (err) throw err; }); From b190f9871341b903a428af66bd42f8474808564e Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 4 Aug 2019 19:21:56 +0200 Subject: [PATCH 04/25] fix typo --- commands/hidden/owned.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/hidden/owned.js b/commands/hidden/owned.js index c3ea47e..e05cb57 100644 --- a/commands/hidden/owned.js +++ b/commands/hidden/owned.js @@ -28,9 +28,9 @@ class OwnedCommand extends Command { if (args.member) { if (args.member.id == this.client.user.id) { - return message.channel.send('You really thought you could own me?, pathethic...'); + return message.channel.send('You really thought you could own me?, pathetic...'); } else if (args.member.id == ownerID) { - return message.channel.send('You really thought you could own him?, pathethic...'); + return message.channel.send('You really thought you could own him?, pathetic...'); } if (ownedMessage == epicMessage[0]) { From 7ef84c3887d059a57dd35cd5590ccd7a6266e3a1 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 6 Aug 2019 19:03:59 +0200 Subject: [PATCH 05/25] Update blacklist --- event/inhibitors/blacklist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/inhibitors/blacklist.js b/event/inhibitors/blacklist.js index 94b987f..a073a59 100644 --- a/event/inhibitors/blacklist.js +++ b/event/inhibitors/blacklist.js @@ -8,7 +8,7 @@ class BlacklistInhibitor extends Inhibitor { } async exec(message) { - const blacklist = ['501856229123948545', '497730155691638784', '29476879240658944', '294768792406589440', '530399670728392737', '595102888796356628']; + const blacklist = ['501856229123948545', '497730155691638784', '29476879240658944', '294768792406589440', '530399670728392737', '595102888796356628', '342039250302140418']; return blacklist.includes(message.author.id); } } From 3ed3bdd3762fb93171af39d6b2617df3d94c650b Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 6 Aug 2019 19:04:11 +0200 Subject: [PATCH 06/25] Use reply --- commands/hidden/owned.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/hidden/owned.js b/commands/hidden/owned.js index e05cb57..eb8839a 100644 --- a/commands/hidden/owned.js +++ b/commands/hidden/owned.js @@ -34,7 +34,7 @@ class OwnedCommand extends Command { } if (ownedMessage == epicMessage[0]) { - return message.channel.send(ownedMessage); + return message.reply(ownedMessage); } return message.channel.send(`${args.member}, ${ownedMessage}`); From 20f96b57ca17795db0b71dea9c1caae7da92d3a6 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 8 Aug 2019 21:24:41 +0200 Subject: [PATCH 07/25] fix typo --- commands/owner/botAvatar.js | 2 +- commands/utility/translate.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/owner/botAvatar.js b/commands/owner/botAvatar.js index 59dbdb2..979e262 100644 --- a/commands/owner/botAvatar.js +++ b/commands/owner/botAvatar.js @@ -25,7 +25,7 @@ class BotAvatarCommand extends Command { let Attachment = (message.attachments).array(); let image = args.image; if (!Attachment[0] && !image) - return message.say('You didint provide any images'); + return message.say('You didn\'t provide any images'); else if (image && !Attachment[0]) { this.client.user.setAvatar(image) .catch(() => message.channel.send('The link you provided dosen\'t work... is it a picture?')); diff --git a/commands/utility/translate.js b/commands/utility/translate.js index ed2c813..174380e 100644 --- a/commands/utility/translate.js +++ b/commands/utility/translate.js @@ -42,7 +42,7 @@ class TranslationCommand extends Command { return response.json(); }).then((response) => { if (response.code == '502') - return message.channel.send(`${response.message}, you probably didin't input the correct language code, you can check them here! https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/`); + return message.channel.send(`${response.message}, you probably didn't input the correct language code, you can check them here! https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/`); else if (response.code != '200') return message.channel.send('An error has occured'); From 26871e0922819b74dbc602833d82d587508563eb Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 11 Aug 2019 19:31:51 +0200 Subject: [PATCH 08/25] fix for updating tag --- commands/admin/tag.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/admin/tag.js b/commands/admin/tag.js index 15f6687..34bf77f 100644 --- a/commands/admin/tag.js +++ b/commands/admin/tag.js @@ -45,8 +45,8 @@ class TagCommand extends Command { const filter = m => m.content && m.author.id == message.author.id; message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] }) .then(async messages => { - let messageContent = messages.map(messages => messages.content); - if (messageContent.tolowerCase() == 'y' || messageContent.tolowerCase() == 'yes') { + let messageContent = messages.map(messages => messages.content.tolowerCase()); + if (messageContent == 'y' || messageContent == 'yes') { const body = {trigger: args.trigger, response: args.response, ownerID: message.author.id, serverID: message.guild.id}; await Tag.update(body, {where: {trigger: args.trigger, serverID: message.guild.id}}); return message.channel.send(`tag have been set to ${args.trigger} : ${args.response}`); From abd5b8a5154d825ed42ac067d03487fb7896b9b0 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 11 Aug 2019 19:33:27 +0200 Subject: [PATCH 09/25] Don't put to lowercase --- commands/admin/tag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/admin/tag.js b/commands/admin/tag.js index 34bf77f..073eee9 100644 --- a/commands/admin/tag.js +++ b/commands/admin/tag.js @@ -45,7 +45,7 @@ class TagCommand extends Command { const filter = m => m.content && m.author.id == message.author.id; message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] }) .then(async messages => { - let messageContent = messages.map(messages => messages.content.tolowerCase()); + let messageContent = messages.map(messages => messages.content); if (messageContent == 'y' || messageContent == 'yes') { const body = {trigger: args.trigger, response: args.response, ownerID: message.author.id, serverID: message.guild.id}; await Tag.update(body, {where: {trigger: args.trigger, serverID: message.guild.id}}); From 34c3e0b1e150beb131ea18a3a4eff8933a3cff86 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 11 Aug 2019 19:54:41 +0200 Subject: [PATCH 10/25] Fake leave message --- commands/fun/fakeleave.js | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 commands/fun/fakeleave.js diff --git a/commands/fun/fakeleave.js b/commands/fun/fakeleave.js new file mode 100644 index 0000000..4254573 --- /dev/null +++ b/commands/fun/fakeleave.js @@ -0,0 +1,70 @@ +const { Command } = require('discord-akairo'); +const fs = require('fs'); +const rand = require('../../rand.js'); + +class fakeleaveCommand extends Command { + constructor() { + super('fakeleave', { + aliases: ['fakeleave'], + category: 'admin', + channelRestriction: 'guild', + args: [ + { + id: 'member', + type: 'member', + match: 'rest' + } + ], + description: { + content: 'Fake leave message', + usage: '[user]', + examples: ['Supositware'] + } + }); + } + + async exec(message, args) { + if (fs.existsSync(`./bye/${message.guild.id}.json`)) { + let member; + if (args.member) { + member = args.member; + } else { + member = message.author; + } + + let bye = require(`../../bye/${message.guild.id}.json`); + + const channel = this.client.channels.get(bye['channel']); + + let byeMessage = bye['message']; + + byeMessage = byeMessage.replace(/\[member\]/, member); + byeMessage = byeMessage.replace(/\[server\]/, message.guild.name); + + let attach; + if (byeMessage.includes('[attach:')) { + attach = byeMessage.split(/(\[attach:.*?])/); + for (let i = 0, l = attach.length; i < l; i++) { + if (attach[i].includes('[attach:')) { + attach = attach[i].replace('[attach:', '').slice(0, -1); + i = attach.length; + } + } + byeMessage = byeMessage.replace(/(\[attach:.*?])/, ''); + } + + byeMessage = rand.random(byeMessage); + + + if (attach) { + return channel.send(byeMessage, {files: [attach]}); + } else { + return channel.send(byeMessage); + } + } else { + return message.channel.send('The server need a leave message first!'); + } + } +} + +module.exports = fakeleaveCommand; \ No newline at end of file From 0039ff999d79fd83b82f064373d432d09ca3fb8a Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 11 Aug 2019 19:55:29 +0200 Subject: [PATCH 11/25] delete previous message --- commands/fun/fakeleave.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/fun/fakeleave.js b/commands/fun/fakeleave.js index 4254573..5792322 100644 --- a/commands/fun/fakeleave.js +++ b/commands/fun/fakeleave.js @@ -55,7 +55,7 @@ class fakeleaveCommand extends Command { byeMessage = rand.random(byeMessage); - + message.delete(); if (attach) { return channel.send(byeMessage, {files: [attach]}); } else { From 4cf0ab03e92dab411d2a69857d69655f988356d7 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 11 Aug 2019 19:56:39 +0200 Subject: [PATCH 12/25] don't ping the person --- commands/fun/fakeleave.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/fun/fakeleave.js b/commands/fun/fakeleave.js index 5792322..ab16778 100644 --- a/commands/fun/fakeleave.js +++ b/commands/fun/fakeleave.js @@ -27,9 +27,9 @@ class fakeleaveCommand extends Command { if (fs.existsSync(`./bye/${message.guild.id}.json`)) { let member; if (args.member) { - member = args.member; + member = args.member.username; } else { - member = message.author; + member = message.author.username; } let bye = require(`../../bye/${message.guild.id}.json`); From 7abd62f842e0d3081996120dd71b60bd8390be57 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 11 Aug 2019 19:59:46 +0200 Subject: [PATCH 13/25] fixed command --- commands/fun/fakeleave.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/fun/fakeleave.js b/commands/fun/fakeleave.js index ab16778..89c3705 100644 --- a/commands/fun/fakeleave.js +++ b/commands/fun/fakeleave.js @@ -11,7 +11,7 @@ class fakeleaveCommand extends Command { args: [ { id: 'member', - type: 'member', + type: 'user', match: 'rest' } ], From ff0762916881f9dfbdc395278f087a0e2635cb59 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 08:48:14 +0200 Subject: [PATCH 14/25] Fakejoin command --- commands/fun/fakejoin.js | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 commands/fun/fakejoin.js diff --git a/commands/fun/fakejoin.js b/commands/fun/fakejoin.js new file mode 100644 index 0000000..f2b0367 --- /dev/null +++ b/commands/fun/fakejoin.js @@ -0,0 +1,70 @@ +const { Command } = require('discord-akairo'); +const fs = require('fs'); +const rand = require('../../rand.js'); + +class fakejoinCommand extends Command { + constructor() { + super('fakejoin', { + aliases: ['fakejoin'], + category: 'admin', + channelRestriction: 'guild', + args: [ + { + id: 'member', + type: 'string', + match: 'rest' + } + ], + description: { + content: 'Fake join message', + usage: '[text]', + examples: ['Supositware'] + } + }); + } + + async exec(message, args) { + if (fs.existsSync(`./welcome/${message.guild.id}.json`)) { + let member; + if (args.member) { + member = args.member; + } else { + member = message.author.username; + } + + let welcome = require(`../../welcome/${message.guild.id}.json`); + + const channel = this.client.channels.get(welcome['channel']); + + let byeMessage = welcome['message']; + + byeMessage = byeMessage.replace(/\[member\]/, member); + byeMessage = byeMessage.replace(/\[server\]/, message.guild.name); + + let attach; + if (byeMessage.includes('[attach:')) { + attach = byeMessage.split(/(\[attach:.*?])/); + for (let i = 0, l = attach.length; i < l; i++) { + if (attach[i].includes('[attach:')) { + attach = attach[i].replace('[attach:', '').slice(0, -1); + i = attach.length; + } + } + byeMessage = byeMessage.replace(/(\[attach:.*?])/, ''); + } + + byeMessage = rand.random(byeMessage); + + message.delete(); + if (attach) { + return channel.send(byeMessage, {files: [attach]}); + } else { + return channel.send(byeMessage); + } + } else { + return message.channel.send('The server need a join message first!'); + } + } +} + +module.exports = fakejoinCommand; \ No newline at end of file From a6843af3a503002c845f6e01db5dd2df6716e029 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 13:46:59 +0200 Subject: [PATCH 15/25] webhook --- .gitignore | 1 + webhook/yes | 0 2 files changed, 1 insertion(+) create mode 100644 webhook/yes diff --git a/.gitignore b/.gitignore index a3b38a8..a24f2cd 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ board/*.json tag/*.json welcome/*.json bye/*.json +webhook/*.json json/censor.json json/uncensor.json diff --git a/webhook/yes b/webhook/yes new file mode 100644 index 0000000..e69de29 From 132a6a0a7c1d59ef62517ecd60101d390717909e Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 13:47:15 +0200 Subject: [PATCH 16/25] fakebot/user --- commands/fun/fakebot.js | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 commands/fun/fakebot.js diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js new file mode 100644 index 0000000..bca2df9 --- /dev/null +++ b/commands/fun/fakebot.js @@ -0,0 +1,63 @@ +const { Command } = require('discord-akairo'); +const fs = require('fs'); + +class fakebotCommand extends Command { + constructor() { + super('fakebot', { + aliases: ['fakebot', 'fakeuser', 'fakemember'], + category: 'fun', + clientPermissions: ['MANAGE_WEBHOOKS'], + args: [ + { + id: 'member', + type: 'user', + prompt: { + start: 'Who should i fake?', + } + }, + { + id: 'message', + type: 'string', + prompt: { + start: 'What message shoudl i send?', + }, + match: 'rest', + } + ], + description: { + content: 'Fake a bot/user with webhook', + usage: '', + examples: [''] + } + }); + } + + async exec(message, args) { + if (!fs.existsSync(`./webhook/${message.guild.id}.json`)) { + message.channel.createWebhook('fakebot') + .then(webhook => { + fs.writeFile(`./webhook/${message.guild.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}"}`, function (err) { + if (err) { + console.log(err); + } + sendWebhook(this.client); + }); + }); + } else { + sendWebhook(this.client); + } + + function sendWebhook(client) { + let webhook = require(`../../webhook/${message.guild.id}.json`); + client.fetchWebhook(webhook.id, webhook.token) + .then(webhook => { + webhook.edit({ + name: args.member.username, + avatar: args.member.displayAvatarURL() + }); + return webhook.send(args.message); + }); + } + } +} +module.exports = fakebotCommand; \ No newline at end of file From f636aa907fd163d5c99ec700b089d773b0f4af6a Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 13:49:43 +0200 Subject: [PATCH 17/25] fix crash --- commands/fun/fakebot.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index bca2df9..a64c094 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -40,24 +40,18 @@ class fakebotCommand extends Command { if (err) { console.log(err); } - sendWebhook(this.client); }); }); - } else { - sendWebhook(this.client); } - - function sendWebhook(client) { - let webhook = require(`../../webhook/${message.guild.id}.json`); - client.fetchWebhook(webhook.id, webhook.token) - .then(webhook => { - webhook.edit({ - name: args.member.username, - avatar: args.member.displayAvatarURL() - }); - return webhook.send(args.message); + let webhook = require(`../../webhook/${message.guild.id}.json`); + this.client.fetchWebhook(webhook.id, webhook.token) + .then(webhook => { + webhook.edit({ + name: args.member.username, + avatar: args.member.displayAvatarURL() }); - } + return webhook.send(args.message); + }); } } module.exports = fakebotCommand; \ No newline at end of file From 7fb3308cf17ada35859d288e35678755b13af5bd Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 13:52:17 +0200 Subject: [PATCH 18/25] delete original message --- commands/fun/fakebot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index a64c094..37c0ae7 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -50,6 +50,7 @@ class fakebotCommand extends Command { name: args.member.username, avatar: args.member.displayAvatarURL() }); + message.channel.delete(); return webhook.send(args.message); }); } From 8166a16a1754d19f8f11123bbe86b6b45bb705d3 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 13:53:37 +0200 Subject: [PATCH 19/25] delete the message, not the channel --- commands/fun/fakebot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 37c0ae7..8774405 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -50,7 +50,7 @@ class fakebotCommand extends Command { name: args.member.username, avatar: args.member.displayAvatarURL() }); - message.channel.delete(); + message.delete(); return webhook.send(args.message); }); } From 4ab1eb3a2df677ac5a96a7da7882d3ebba9b05a2 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 14:05:39 +0200 Subject: [PATCH 20/25] don't actually crash --- commands/fun/fakebot.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 8774405..932bc52 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -40,19 +40,27 @@ class fakebotCommand extends Command { if (err) { console.log(err); } + return message.channel.send('Please run me again to send the message!'); }); }); - } - let webhook = require(`../../webhook/${message.guild.id}.json`); - this.client.fetchWebhook(webhook.id, webhook.token) - .then(webhook => { - webhook.edit({ - name: args.member.username, - avatar: args.member.displayAvatarURL() + } else { + let webhook = require(`../../webhook/${message.guild.id}.json`); + this.client.fetchWebhook(webhook.id, webhook.token) + .then(webhook => { + webhook.edit({ + name: args.member.username, + avatar: args.member.displayAvatarURL() + }); + + webhook.edit({ + name: args.member.username, + avatar: args.member.displayAvatarURL() + }); + + message.delete(); + return webhook.send(args.message); }); - message.delete(); - return webhook.send(args.message); - }); + } } } module.exports = fakebotCommand; \ No newline at end of file From c940aa8d3e71aa2ec955725d7402ebdbbd2412e7 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 14:08:06 +0200 Subject: [PATCH 21/25] reload the json --- commands/fun/fakebot.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 932bc52..9fd3208 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -1,5 +1,6 @@ const { Command } = require('discord-akairo'); const fs = require('fs'); +const reload = require('auto-reload'); class fakebotCommand extends Command { constructor() { @@ -44,7 +45,7 @@ class fakebotCommand extends Command { }); }); } else { - let webhook = require(`../../webhook/${message.guild.id}.json`); + let webhook = reload(`../../webhook/${message.guild.id}.json`); this.client.fetchWebhook(webhook.id, webhook.token) .then(webhook => { webhook.edit({ @@ -52,11 +53,6 @@ class fakebotCommand extends Command { avatar: args.member.displayAvatarURL() }); - webhook.edit({ - name: args.member.username, - avatar: args.member.displayAvatarURL() - }); - message.delete(); return webhook.send(args.message); }); From 46ea45859510fbafc28f06572e0de68b8bcd0b7d Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 14:18:45 +0200 Subject: [PATCH 22/25] a webhook per channel --- commands/fun/fakebot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 9fd3208..896eef3 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -20,7 +20,7 @@ class fakebotCommand extends Command { id: 'message', type: 'string', prompt: { - start: 'What message shoudl i send?', + start: 'What message should i send?', }, match: 'rest', } @@ -34,10 +34,10 @@ class fakebotCommand extends Command { } async exec(message, args) { - if (!fs.existsSync(`./webhook/${message.guild.id}.json`)) { + if (fs.existsSync(`./webhook/${message.guild.id}_${message.channel.id}.json`)) { message.channel.createWebhook('fakebot') .then(webhook => { - fs.writeFile(`./webhook/${message.guild.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}"}`, function (err) { + fs.writeFile(`./webhook/${message.guild.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}", "channel": "${message.channel.id}"}`, function (err) { if (err) { console.log(err); } @@ -45,7 +45,7 @@ class fakebotCommand extends Command { }); }); } else { - let webhook = reload(`../../webhook/${message.guild.id}.json`); + let webhook = reload(`./webhook/${message.guild.id}_${message.channel.id}.json`); this.client.fetchWebhook(webhook.id, webhook.token) .then(webhook => { webhook.edit({ From 4dc3612986965a7617b48518506ac9dd1025a2fe Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 14:19:58 +0200 Subject: [PATCH 23/25] whoops --- commands/fun/fakebot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 896eef3..b9b9881 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -34,7 +34,7 @@ class fakebotCommand extends Command { } async exec(message, args) { - if (fs.existsSync(`./webhook/${message.guild.id}_${message.channel.id}.json`)) { + if (!fs.existsSync(`./webhook/${message.guild.id}_${message.channel.id}.json`)) { message.channel.createWebhook('fakebot') .then(webhook => { fs.writeFile(`./webhook/${message.guild.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}", "channel": "${message.channel.id}"}`, function (err) { From 3a505e4cd99d7aff5c4ef1024c5ab9a54cf6c179 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 14:20:59 +0200 Subject: [PATCH 24/25] write the file correctly --- commands/fun/fakebot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index b9b9881..2408a1a 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -37,7 +37,7 @@ class fakebotCommand extends Command { if (!fs.existsSync(`./webhook/${message.guild.id}_${message.channel.id}.json`)) { message.channel.createWebhook('fakebot') .then(webhook => { - fs.writeFile(`./webhook/${message.guild.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}", "channel": "${message.channel.id}"}`, function (err) { + fs.writeFile(`./webhook/${message.guild.id}_${message.channel.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}", "channel": "${message.channel.id}"}`, function (err) { if (err) { console.log(err); } From ae97f04bc95fc556529efaae740250eebf2915cc Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 14:23:26 +0200 Subject: [PATCH 25/25] require at the right directory --- commands/fun/fakebot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 2408a1a..325516e 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -45,7 +45,7 @@ class fakebotCommand extends Command { }); }); } else { - let webhook = reload(`./webhook/${message.guild.id}_${message.channel.id}.json`); + let webhook = reload(`../../webhook/${message.guild.id}_${message.channel.id}.json`); this.client.fetchWebhook(webhook.id, webhook.token) .then(webhook => { webhook.edit({