16 |
if (cm.args[1] !== undefined) { |
if (cm.args[1] !== undefined) { |
17 |
let args = [...cm.args]; |
let args = [...cm.args]; |
18 |
args.shift(); |
args.shift(); |
19 |
genurl += `&q=${escape(args.join(' '))}`; |
let q = new URLSearchParams({q: args.join(' ')}).toString(); |
20 |
|
console.log(q); |
21 |
|
genurl += `&${q}`; |
22 |
} |
} |
23 |
|
|
24 |
axios.get(genurl) |
axios.get(genurl) |
25 |
.then(res => { |
.then(res => { |
26 |
if (res && res.status === 200) { |
if (res && res.status === 200) { |
27 |
//console.log(res.data); |
//console.log(res.data.hits); |
28 |
|
if (!res.data.hits || res.data.hits?.length < 1) { |
29 |
|
msg.reply({ |
30 |
|
content: ":x: No search result found from the API." |
31 |
|
}); |
32 |
|
|
33 |
|
return; |
34 |
|
} |
35 |
|
|
36 |
msg.reply({ |
msg.reply({ |
37 |
content: random(res.data.hits).largeImageURL |
content: random(res.data.hits).largeImageURL |
38 |
}); |
}); |
39 |
} |
} |
40 |
}) |
}) |
41 |
.catch(err => { |
.catch(err => { |
42 |
|
console.log(err.message); |
43 |
msg.reply({ |
msg.reply({ |
44 |
embeds: [ |
embeds: [ |
45 |
new MessageEmbed() |
new MessageEmbed() |