diff --git a/bot.js b/bot.js index 33d7207..9d2e200 100644 --- a/bot.js +++ b/bot.js @@ -228,9 +228,13 @@ async function loadJson(url, auth) { let response; if (auth) { - response = await fetch(url, auth); - sendToBotTestingChannel('imgur url:' + url); - sendToBotTestingChannel('imgur auth:' + JSON.stringify(auth)); + response = await fetch(url, { + headers: { + Authorization: 'Client-ID ' + auth, + credentials: 'same-origin', + Accept: 'application/json' + } + }); } else { response = await fetch(url); } @@ -254,18 +258,9 @@ async function asyncImageRequest(channelMessage) { //collect all the json let image_url_list = []; let reddit_json = await loadJson("https://www.reddit.com/r/" + requested_item + "/.json?show=all&count=25&limit=100"); - let imgur_json = await loadJson( - 'https://api.imgur.com/3/gallery/r/' + requested_item + '/time/' + getRandomInt(1, 5), - { - headers: { - Authorization: 'Client-ID ' + auth.imgur, - credentials: 'same-origin', - Accept: 'application/json' - } - } - ); + let imgur_json = await loadJson('https://api.imgur.com/3/gallery/r/' + requested_item + '/time/' + getRandomInt(1, 5), auth.imgur); - console.log('imgur_json -> ' + JSON.stringify(imgur_json)); + //console.log('imgur_json -> ' + JSON.stringify(imgur_json)); // todo need to check config to see if it's a valid booruuuuu //let redditbooru_json = await loadJson("https://" + requested_item + ".redditbooru.com/images/?limit=1000");