This commit is contained in:
Ashley Graves 2024-10-10 13:15:01 +02:00
parent 84a6a57aa6
commit a4c8572303
3 changed files with 33 additions and 2 deletions

View file

@ -8,6 +8,7 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@imgproxy/imgproxy-node": "^1.0.6",
"booru": "^2.6.8", "booru": "^2.6.8",
"discord.js": "^14.16.3", "discord.js": "^14.16.3",
"dotenv": "^16.4.5", "dotenv": "^16.4.5",

View file

@ -8,6 +8,9 @@ importers:
.: .:
dependencies: dependencies:
'@imgproxy/imgproxy-node':
specifier: ^1.0.6
version: 1.0.6
booru: booru:
specifier: ^2.6.8 specifier: ^2.6.8
version: 2.6.8 version: 2.6.8
@ -57,6 +60,12 @@ packages:
resolution: {integrity: sha512-PZ+vLpxGCRtmr2RMkqh8Zp+BenUaJqlS6xhgWKEZcgC/vfHLEzpHtKkB0sl3nZWpwtcKk6YWy+pU3okL2I97FA==} resolution: {integrity: sha512-PZ+vLpxGCRtmr2RMkqh8Zp+BenUaJqlS6xhgWKEZcgC/vfHLEzpHtKkB0sl3nZWpwtcKk6YWy+pU3okL2I97FA==}
engines: {node: '>=16.11.0'} engines: {node: '>=16.11.0'}
'@imgproxy/imgproxy-js-core@1.0.8':
resolution: {integrity: sha512-3oBneumj7b/YCeyLteKyKaidQSrDhEHnZMiVBHO0Hshju/YSplbzSeACZGwai7LyD3YMMpsK/kLIodXU6wbtMw==}
'@imgproxy/imgproxy-node@1.0.6':
resolution: {integrity: sha512-Evdg3Ywry4RzIKTtQnHO3KsSKHa000GcdY4nRM2JRNdAgATv7fBD82nj6qzTgcqxpqcywnT1Sd2XGxxVg7ZC+w==}
'@sapphire/async-queue@1.5.3': '@sapphire/async-queue@1.5.3':
resolution: {integrity: sha512-x7zadcfJGxFka1Q3f8gCts1F0xMwCKbZweM85xECGI0hBTeIZJGGCrHgLggihBoprlQ/hBmDR5LKfIPqnmHM3w==} resolution: {integrity: sha512-x7zadcfJGxFka1Q3f8gCts1F0xMwCKbZweM85xECGI0hBTeIZJGGCrHgLggihBoprlQ/hBmDR5LKfIPqnmHM3w==}
engines: {node: '>=v14.0.0', npm: '>=7.0.0'} engines: {node: '>=v14.0.0', npm: '>=7.0.0'}
@ -287,6 +296,12 @@ snapshots:
- bufferutil - bufferutil
- utf-8-validate - utf-8-validate
'@imgproxy/imgproxy-js-core@1.0.8': {}
'@imgproxy/imgproxy-node@1.0.6':
dependencies:
'@imgproxy/imgproxy-js-core': 1.0.8
'@sapphire/async-queue@1.5.3': {} '@sapphire/async-queue@1.5.3': {}
'@sapphire/shapeshift@4.0.0': '@sapphire/shapeshift@4.0.0':

View file

@ -1,6 +1,7 @@
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder, EmbedBuilder, escapeMarkdown, bold, ButtonBuilder, ButtonStyle } = require("discord.js"); const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder, EmbedBuilder, escapeMarkdown, bold, ButtonBuilder, ButtonStyle } = require("discord.js");
const { Pagination } = require('pagination.djs'); const { generateImageUrl } = require('@imgproxy/imgproxy-node');
const { stringify } = require("node:querystring"); const { stringify } = require("node:querystring");
const { Pagination } = require('pagination.djs');
const data = new SlashCommandBuilder() const data = new SlashCommandBuilder()
.setName("isrch") .setName("isrch")
@ -25,6 +26,20 @@ function notEmpty(str) {
return str.trim() !== '' return str.trim() !== ''
} }
function proxy(url) {
if (!process.env.IMGPROXY_HOST)
return url;
url = generateImageUrl({
endpoint: process.env.IMGPROXY_HOST,
url: url,
salt: process.env.IMGPROXY_SALT,
key: process.env.IMGPROXY_KEY
});
return url;
}
module.exports = { module.exports = {
data, data,
async execute(interaction) { async execute(interaction) {
@ -49,7 +64,7 @@ module.exports = {
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor("#cba6f7") .setColor("#cba6f7")
.setImage(result.img_src) .setImage(proxy(result.img_src))
.setFooter({ .setFooter({
text: result.engine text: result.engine
}); });