AtoraSuunva / booru

Searches boorus for images using some js magic
https://www.npmjs.com/package/booru
MIT License
78 stars 19 forks source link

Cannot read property \'length\' of undefined (Sorry if this has been answered) #14

Closed Fezezen closed 6 years ago

Fezezen commented 6 years ago

Sorry if this has been answered somewhere, I searched around and couldn't find anything, I understand alot in Javascript but I'm kind of new to it. I'm making a r34 function for my discord bot and I found this on npm, I tried this V what you see below, but no matter what I do to it, or even use the example provided the console spits this BooruError : "Cannot read property \'length\' of undefined", I'm using discord.js if you wanted to know.

try { const booruData = await booru.search('rule34.xxx', args, { 'limit': 1, 'random': true }).then(booru.commonfy);

             if (booruData) {
               message.delete(200);

               return message.channel.send(`Score: ${booruData[0].common.score}\n Image: ${booruData[0].common.file_url}`);
            }

        return message.reply('⚠️ No juicy images found.');

} catch (BooruError) { console.log(BooruError); return message.reply('⚠️ No juicy images found.(err)'); }

Fezezen commented 6 years ago

Here's my Repo for the bot if you want to look at it: https://github.com/Fezezen/Tsumiki-san

Fezezen commented 6 years ago

I just used another library.

AtoraSuunva commented 6 years ago

What version are you using? I checked your repo and it looks like you're using 0.5.0, which was the start of my rewrite and is broken when using it with boorus that return XML

Try installing the latest (0.4.0) version instead; I'll go work on removing 0.5.0 from npm (Which never should've been there in the first place :/)