-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxkcd.js
More file actions
27 lines (24 loc) · 670 Bytes
/
xkcd.js
File metadata and controls
27 lines (24 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const Discord = require("discord.js");
Array.prototype.randomNumber = function () {
}
module.exports = {
new: function(newest = null) {
let comicUrl = "https://xkcd.com/info.0.json"
if (newest == null) {
let comicNumber = Math.floor(Math.random() * 2130)
comicUrl = `https://xkcd.com/${comicNumber}/info.0.json`
}
return fetch(comicUrl)
.then(function(response) {
return response.json()
})
.then(function(json) {
let comic = json.img
const embeddedMsg = {
title: json.title,
image: { url: json.img }
}
return embeddedMsg
})
}
}