choose random pages too
This commit is contained in:
parent
49055ca2a0
commit
6cac87a30d
1 changed files with 5 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue