mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-04 15:56:52 +02:00
Fix undefined
This commit is contained in:
@@ -29,7 +29,10 @@ module.exports = class AnagramCommand extends Command {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`http://www.anagramica.com/best/${word}`);
|
||||
if (!body.best.length) return msg.say('Could not find any results.');
|
||||
const words = strict ? body.best.filter(anagram => anagram.length === word.length) : body.best;
|
||||
const all = body.best.filter(anagram => anagram.toLowerCase() !== word);
|
||||
if (!all.length) return msg.say('Could not find any results.');
|
||||
const words = strict ? all.filter(anagram => anagram.length === word.length) : all;
|
||||
if (!words.length) return msg.say('Could not find any results.');
|
||||
return msg.say(words[Math.floor(Math.random() * words.length)]);
|
||||
} catch (err) {
|
||||
if (err.status === 500) return msg.say('Could not find any results.');
|
||||
|
||||
Reference in New Issue
Block a user