Switched image result provider from DuckDuckGo to Searx
This commit is contained in:
parent
4231b0d2a2
commit
3935a7490a
4 changed files with 16 additions and 121 deletions
|
@ -1,5 +1,7 @@
|
|||
const paginator = require("../../utils/pagination/pagination.js");
|
||||
const { image_search } = require("duckduckgo-images-api");
|
||||
const { searx } = require("../../servers.json");
|
||||
const { random } = require("../../utils/misc.js");
|
||||
const fetch = require("node-fetch");
|
||||
const Command = require("../../classes/command.js");
|
||||
|
||||
class ImageSearchCommand extends Command {
|
||||
|
@ -8,19 +10,20 @@ class ImageSearchCommand extends Command {
|
|||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||
if (this.args.length === 0) return "You need to provide something to search for!";
|
||||
const embeds = [];
|
||||
const images = await image_search({ query: this.args.join(" "), moderate: true });
|
||||
if (images.error && images.error.code === 403) return "The daily search quota has been exceeded. Check back later.";
|
||||
if (images.length === 0) return "I couldn't find any results!";
|
||||
for (const [i, value] of images.entries()) {
|
||||
const images = await fetch(`${random(searx)}/search?format=json&safesearch=1&categories=images&disabled_engines=flickr__images,ccengine__images,library of congress__images,deviantart__images,bing images__images&q=${encodeURIComponent(this.args.join(" "))}`).then(res => res.json());
|
||||
//if (images.error && images.error.code === 403) return "The daily search quota has been exceeded. Check back later.";
|
||||
if (images.results.length === 0) return "I couldn't find any results!";
|
||||
for (const [i, value] of images.results.entries()) {
|
||||
embeds.push({
|
||||
"embed": {
|
||||
"title": "Search Results",
|
||||
"color": 16711680,
|
||||
"footer": {
|
||||
"text": `Page ${i + 1} of ${images.length}`
|
||||
"text": `Page ${i + 1} of ${images.results.length}`
|
||||
},
|
||||
"description": `[${value.title}](${encodeURI(value.img_src)})`,
|
||||
"image": {
|
||||
"url": value.image
|
||||
"url": encodeURI(value.img_src)
|
||||
},
|
||||
"author": {
|
||||
"name": this.message.author.username,
|
||||
|
@ -32,7 +35,7 @@ class ImageSearchCommand extends Command {
|
|||
return paginator(this.client, this.message, embeds);
|
||||
}
|
||||
|
||||
static description = "Searches for images on DuckDuckGo";
|
||||
static description = "Searches for images across the web";
|
||||
static aliases = ["im", "photo", "img"];
|
||||
static arguments = ["[query]"];
|
||||
}
|
||||
|
|
114
package-lock.json
generated
114
package-lock.json
generated
|
@ -1,19 +1,18 @@
|
|||
{
|
||||
"name": "esmbot",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "esmbot",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@top-gg/sdk": "^3.1.1",
|
||||
"cowsay2": "^2.0.4",
|
||||
"dayjs": "^1.10.4",
|
||||
"dotenv": "^9.0.2",
|
||||
"duckduckgo-images-api": "^1.0.5",
|
||||
"emoji-regex": "^9.2.2",
|
||||
"eris": "^0.15.0",
|
||||
"eris-sharder": "github:esmBot/eris-sharder#eris-dev",
|
||||
|
@ -581,16 +580,6 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.18.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
|
||||
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
|
||||
"deprecated": "Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410",
|
||||
"dependencies": {
|
||||
"follow-redirects": "1.5.10",
|
||||
"is-buffer": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
|
@ -1089,14 +1078,6 @@
|
|||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/duckduckgo-images-api": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/duckduckgo-images-api/-/duckduckgo-images-api-1.0.5.tgz",
|
||||
"integrity": "sha512-54EW2AD/VOEizdRo23nHnTI/VNgRmVyR7MkCHYqBdvlTkSUYg+uMCTETd6GgU+9ohnCJUUDD9cC3rvw9RnuLcw==",
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.3.728",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.728.tgz",
|
||||
|
@ -1632,30 +1613,6 @@
|
|||
"integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.5.10",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
||||
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
||||
"dependencies": {
|
||||
"debug": "=3.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects/node_modules/debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"node_modules/fs-constants": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
||||
|
@ -1913,28 +1870,6 @@
|
|||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
|
||||
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
|
||||
},
|
||||
"node_modules/is-buffer": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
|
||||
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/is-extglob": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||
|
@ -4185,15 +4120,6 @@
|
|||
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
|
||||
"dev": true
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.18.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
|
||||
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
|
||||
"requires": {
|
||||
"follow-redirects": "1.5.10",
|
||||
"is-buffer": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
|
@ -4568,14 +4494,6 @@
|
|||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-9.0.2.tgz",
|
||||
"integrity": "sha512-I9OvvrHp4pIARv4+x9iuewrWycX6CcZtoAu1XrzPxc5UygMJXJZYmBsynku8IkrJwgypE5DGNjDPmPRhDCptUg=="
|
||||
},
|
||||
"duckduckgo-images-api": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/duckduckgo-images-api/-/duckduckgo-images-api-1.0.5.tgz",
|
||||
"integrity": "sha512-54EW2AD/VOEizdRo23nHnTI/VNgRmVyR7MkCHYqBdvlTkSUYg+uMCTETd6GgU+9ohnCJUUDD9cC3rvw9RnuLcw==",
|
||||
"requires": {
|
||||
"axios": "^0.18.0"
|
||||
}
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.728",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.728.tgz",
|
||||
|
@ -4980,29 +4898,6 @@
|
|||
"integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==",
|
||||
"dev": true
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.5.10",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
||||
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
||||
"requires": {
|
||||
"debug": "=3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
}
|
||||
}
|
||||
},
|
||||
"fs-constants": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
||||
|
@ -5197,11 +5092,6 @@
|
|||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
|
||||
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
|
||||
},
|
||||
"is-buffer": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
|
||||
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="
|
||||
},
|
||||
"is-extglob": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
"cowsay2": "^2.0.4",
|
||||
"dayjs": "^1.10.4",
|
||||
"dotenv": "^9.0.2",
|
||||
"duckduckgo-images-api": "^1.0.5",
|
||||
"emoji-regex": "^9.2.2",
|
||||
"eris": "^0.15.0",
|
||||
"eris-sharder": "github:esmBot/eris-sharder#eris-dev",
|
||||
|
|
|
@ -4,5 +4,8 @@
|
|||
],
|
||||
"image": [
|
||||
"localhost"
|
||||
],
|
||||
"searx": [
|
||||
"https://searx.xyz"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue