From 6cac87a30d247f49607996ac0232eb337d255a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Wed, 26 Jun 2019 15:15:26 +0200 Subject: [PATCH] choose random pages too --- commands/fun/4chan.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/fun/4chan.js b/commands/fun/4chan.js index a8b81dd3..2b610cb8 100644 --- a/commands/fun/4chan.js +++ b/commands/fun/4chan.js @@ -32,13 +32,16 @@ class FourchanCommand extends Command { if (!args.board) return; - fetch(`https://a.4cdn.org/${args.board}/1.json`).then((response) => { + let i = Math.floor((Math.random() * 5) + 1); + + + fetch(`https://a.4cdn.org/${args.board}/${i}.json`).then((response) => { return response.json(); }).then((response) => { if (!response.threads) return message.channel.send('Not a valid board'); - let i = Math.floor((Math.random() * response.threads.length)); + i = Math.floor((Math.random() * response.threads.length) + 1); // If post is sticky search again while(response.threads[i].posts[0].sticky == 1) {