Make pagination use interactions instead of reactions, filter out base64 images in image

This commit is contained in:
Essem 2021-08-12 18:45:17 -05:00
parent 5c0cb6463a
commit da709c485f
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
5 changed files with 119 additions and 40 deletions

View file

@ -11,15 +11,16 @@ class ImageSearchCommand extends Command {
if (this.args.length === 0) return "You need to provide something to search for!";
await this.message.channel.sendTyping();
const embeds = [];
const images = await fetch(`${random(searx)}/search?format=json&safesearch=2&categories=images&q=!goi%20!bii%20!ddi%20${encodeURIComponent(this.args.join(" "))}`).then(res => res.json());
if (images.results.length === 0) return "I couldn't find any results!";
for (const [i, value] of images.results.entries()) {
const rawImages = await fetch(`${random(searx)}/search?format=json&safesearch=2&categories=images&q=!goi%20!bii%20!ddi%20${encodeURIComponent(this.args.join(" "))}`).then(res => res.json());
if (rawImages.results.length === 0) return "I couldn't find any results!";
const images = rawImages.results.filter((val) => !val.img_src.startsWith("data:image"));
for (const [i, value] of images.entries()) {
embeds.push({
"embed": {
"title": "Search Results",
"color": 16711680,
"footer": {
"text": `Page ${i + 1} of ${images.results.length}`
"text": `Page ${i + 1} of ${images.length}`
},
"description": value.title,
"image": {