From 558a789e925a5cef66659e599a4c00e4a767e456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Wed, 26 Jun 2019 04:13:24 +0200 Subject: [PATCH] if webm send it as separate link --- commands/fun/4chan.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/commands/fun/4chan.js b/commands/fun/4chan.js index ae7738ad..a3a23458 100644 --- a/commands/fun/4chan.js +++ b/commands/fun/4chan.js @@ -40,7 +40,12 @@ class FourchanCommand extends Command { let i = Math.floor((Math.random() * response.threads.length)); - let description = response.threads[i].posts[0].com.replace(/(<([^>]+)>)/ig,''); + let description = response.threads[i].posts[0].com; + + let regex = /(<([^>]+)>)/ig; + if (regex.test(description)) { + description = response.threads[i].posts[0].com.replace(/(<([^>]+)>)/ig,''); + } description = decodeURI(description); const FourchanEmbed = new MessageEmbed() @@ -52,7 +57,13 @@ class FourchanCommand extends Command { .setFooter(`${boards.getName(args.board)} | ${response.threads[i].posts[0].now}`) .setTimestamp(); - message.channel.send(FourchanEmbed); + if (response.threads[i].posts[0].ext == '.webm') { + message.channel.send(FourchanEmbed); + message.channel.send(`https://i.4cdn.org/${args.board}/${response.threads[i].posts[0].tim}${response.threads[i].posts[0].ext}`); + + } else { + message.channel.send(FourchanEmbed); + } }); } }