mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-10 19:04:42 +02:00
Fix safebooru
This commit is contained in:
@@ -22,7 +22,7 @@ module.exports = class SafebooruCommand extends Command {
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
const { text } = await snekfetch
|
||||
.get('https://safebooru.org/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
@@ -32,7 +32,8 @@ module.exports = class SafebooruCommand extends Command {
|
||||
tags: query,
|
||||
limit: 200
|
||||
});
|
||||
if (!body) return msg.say('Could not find any results.');
|
||||
if (!text) return msg.say('Could not find any results.');
|
||||
const body = JSON.parse(text);
|
||||
const data = body[Math.floor(Math.random() * body.length)];
|
||||
return msg.say(`https://safebooru.org/images/${data.directory}/${data.image}`);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user