From 043ddde69923fe0715d843538dbfc22da5d501cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Wed, 8 May 2019 22:57:22 +0200 Subject: [PATCH] Added [attach:] --- event/listeners/message.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index 9fcac61..4c62f01 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -60,6 +60,20 @@ class messageListener extends Listener { } text = rand.random(text, message); + + let attach = ''; + + if (text.includes('[attach')) { + attach = text.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; + } + } + text = text.replace(/(\[attach:.*?])/, '') + } + // THIS SECTION IS VERY VERY BAD MUST CHANGE if (text.includes('[embed]')) { text = text.replace(/\[embed\]/, ' '); @@ -149,11 +163,20 @@ class messageListener extends Listener { .setTimestamp(); - return message.channel.send(embed); - } - - message.channel.send(text); + if (attach) { + return message.channel.send(embed, {files: [attach]}); + } else { + return message.channel.send(embed); + } + } + + if (attach) { + return message.channel.send(text, {files: [attach]}); + } else { + return message.channel.send(text); + } } + } catch (err) { null; }