imgur auth attempt
This commit is contained in:
15
bot.js
15
bot.js
@@ -216,8 +216,14 @@ function getUrlListFromRedditBooru(json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Async request of a page that returns JSON.
|
// Async request of a page that returns JSON.
|
||||||
async function loadJson(url) {
|
async function loadJson(url, auth) {
|
||||||
let response = await fetch(url);
|
|
||||||
|
let response;
|
||||||
|
if (auth) {
|
||||||
|
response = await fetch(url, auth);
|
||||||
|
} else {
|
||||||
|
response = await fetch(url);
|
||||||
|
}
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
return response.json();
|
return response.json();
|
||||||
} else {
|
} else {
|
||||||
@@ -238,7 +244,10 @@ async function asyncImageRequest(channelMessage) {
|
|||||||
//collect all the json
|
//collect all the json
|
||||||
let image_url_list = [];
|
let image_url_list = [];
|
||||||
let reddit_json = await loadJson("https://www.reddit.com/r/" + requested_item + "/.json?show=all&count=25&limit=100");
|
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));
|
let imgur_json = await loadJson(
|
||||||
|
'https://api.imgur.com/3/gallery/r/' + requested_item + '/time/' + getRandomInt(1, 5),
|
||||||
|
{'Authorization': 'Client-ID ' + auth.imgur}
|
||||||
|
);
|
||||||
// todo need to check config to see if it's a valid booruuuuu
|
// 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");
|
//let redditbooru_json = await loadJson("https://" + requested_item + ".redditbooru.com/images/?limit=1000");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user