diff --git a/src/commands/fun/gelbooru.js b/src/commands/fun/gelbooru.js index 2b56e1f..c11f960 100644 --- a/src/commands/fun/gelbooru.js +++ b/src/commands/fun/gelbooru.js @@ -147,7 +147,11 @@ module.exports = { const searchTags = [rating, ...tags, ...[...blacklist, ...userBlacklist].map(i => "-" + i)]; const startTime = process.hrtime.bigint(); - var post = (await Booru.search(booru, searchTags, { limit: 1, random: true, credentials: credentials[booru] ?? null }))[0]; + var tries = 0; + var post; + while (post.length == 0 && (tries++) < 5) + post = await Booru.search(booru, searchTags, { limit: 1, random: true, credentials: credentials[booru] ?? null }); + if (post == null) { await interaction.followUp(emojis.warning + " Could not find any post matching tags."); return;