This commit is contained in:
Ashley Graves 2024-10-10 14:53:00 +02:00
parent 8d7357e4da
commit 89fca15655

View file

@ -1,4 +1,5 @@
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder, EmbedBuilder, escapeMarkdown, bold } = require("discord.js"); const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder, EmbedBuilder, escapeMarkdown, bold } = require("discord.js");
const { generateImageUrl } = require('@imgproxy/imgproxy-node');
const { stringify } = require("node:querystring"); const { stringify } = require("node:querystring");
const { readFileSync } = require("node:fs"); const { readFileSync } = require("node:fs");
const { decode } = require("html-entities"); const { decode } = require("html-entities");
@ -105,6 +106,20 @@ function isAIPost(post) {
var credentials = JSON.parse(readFileSync("credentials.json")); var credentials = JSON.parse(readFileSync("credentials.json"));
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) {
@ -156,7 +171,7 @@ module.exports = {
.setTitle(`Post #${post.id}`) .setTitle(`Post #${post.id}`)
.setURL(post.postView) .setURL(post.postView)
.setDescription(description) .setDescription(description)
.setImage(post.fileUrl) .setImage(proxy(post.fileUrl))
.setFooter({ .setFooter({
text: footerText, text: footerText,
iconURL: `https://${post.booru.domain}/favicon.ico`, iconURL: `https://${post.booru.domain}/favicon.ico`,