guh
This commit is contained in:
parent
e9403a5bc9
commit
7d2b9f51f6
11 changed files with 135 additions and 105 deletions
|
@ -1,5 +1,8 @@
|
||||||
{
|
{
|
||||||
"warning": "<:warning:1293874152150667315>",
|
"warning": "<:warning:1293874152150667315>",
|
||||||
|
"green_arrow_up": "<:green_arrow_up:1293819944399667222>",
|
||||||
|
"red_arrow_down": "<:red_arrow_down:1293819951764869181>",
|
||||||
|
"yellow_tilde": "<:yellow_tilde:1293819958643396608>",
|
||||||
"booru": {
|
"booru": {
|
||||||
"rating": {
|
"rating": {
|
||||||
"safe": "<:rating_safe:1293819920978804829>",
|
"safe": "<:rating_safe:1293819920978804829>",
|
||||||
|
@ -7,11 +10,6 @@
|
||||||
"questionable": "<:rating_questionable:1293819907099725925>",
|
"questionable": "<:rating_questionable:1293819907099725925>",
|
||||||
"explicit": "<:rating_explicit:1293819893795389491>",
|
"explicit": "<:rating_explicit:1293819893795389491>",
|
||||||
"unknown": "<:rating_unknown:1293819936845594665>"
|
"unknown": "<:rating_unknown:1293819936845594665>"
|
||||||
},
|
|
||||||
"score": {
|
|
||||||
"green_arrow_up": "<:green_arrow_up:1293819944399667222>",
|
|
||||||
"red_arrow_down": "<:red_arrow_down:1293819951764869181>",
|
|
||||||
"yellow_tilde": "<:yellow_tilde:1293819958643396608>"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
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 { generateImageUrl } = require('@imgproxy/imgproxy-node');
|
||||||
|
const { extname, basename } = require("node:path");
|
||||||
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");
|
||||||
const { extname, basename } = require("node:path");
|
|
||||||
const { knex } = require("../../db.js");
|
const { knex } = require("../../db.js");
|
||||||
const Booru = require("@himeka/booru");
|
const Booru = require("@himeka/booru");
|
||||||
|
|
||||||
|
@ -82,11 +82,11 @@ function formatRating(rating) {
|
||||||
|
|
||||||
function formatScore(score) {
|
function formatScore(score) {
|
||||||
if (score > 0) {
|
if (score > 0) {
|
||||||
return `${emojis.booru.score.green_arrow_up} ${score}`
|
return `${emojis.green_arrow_up} ${score}`
|
||||||
} else if (score < 0) {
|
} else if (score < 0) {
|
||||||
return `${emojis.booru.score.red_arrow_down} ${score}`
|
return `${emojis.red_arrow_down} ${score}`
|
||||||
} else {
|
} else {
|
||||||
return `${emojis.booru.score.yellow_tilde} ${score}`
|
return `${emojis.yellow_tilde} ${score}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder, EmbedBuilder, escapeMarkdown, bold, ButtonBuilder, ButtonStyle } = require("discord.js");
|
|
||||||
const { generateImageUrl } = require('@imgproxy/imgproxy-node');
|
|
||||||
const { stringify } = require("node:querystring");
|
|
||||||
const { Pagination } = require('pagination.djs');
|
|
||||||
|
|
||||||
const data = new SlashCommandBuilder()
|
|
||||||
.setName("isrch")
|
|
||||||
.setDescription("SearxNG-powered image search")
|
|
||||||
.addStringOption(builder =>
|
|
||||||
builder //
|
|
||||||
.setName("query")
|
|
||||||
.setRequired(true)
|
|
||||||
.setDescription("What to search for")
|
|
||||||
)
|
|
||||||
.setContexts([
|
|
||||||
InteractionContextType.Guild,
|
|
||||||
InteractionContextType.BotDM,
|
|
||||||
InteractionContextType.PrivateChannel
|
|
||||||
])
|
|
||||||
.setIntegrationTypes([
|
|
||||||
ApplicationIntegrationType.GuildInstall,
|
|
||||||
ApplicationIntegrationType.UserInstall
|
|
||||||
]);
|
|
||||||
|
|
||||||
function notEmpty(str) {
|
|
||||||
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 = {
|
|
||||||
data,
|
|
||||||
async execute(interaction) {
|
|
||||||
const query = interaction.options.getString("query");
|
|
||||||
await interaction.deferReply();
|
|
||||||
|
|
||||||
var queryString = stringify({
|
|
||||||
"category_images": "",
|
|
||||||
"format": "json",
|
|
||||||
"q": "!goi " + query
|
|
||||||
});
|
|
||||||
|
|
||||||
const embeds = [];
|
|
||||||
const data = await (await fetch(`https://s.koda.re/search?${queryString}`)).json();
|
|
||||||
for (const result of data.results) {
|
|
||||||
if (result.img_src == '') continue;
|
|
||||||
|
|
||||||
var description = result.source ?? result.title;
|
|
||||||
if (description.length > 1024) description = description.slice(0, 1021) + "...";
|
|
||||||
|
|
||||||
if (result.img_src.startsWith("//")) result.img_src = "http:" + result.img_src
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setColor("#cba6f7")
|
|
||||||
.setImage(proxy(result.img_src))
|
|
||||||
.setFooter({
|
|
||||||
text: result.engines.join(", ")
|
|
||||||
});
|
|
||||||
|
|
||||||
if (description.length >= 1)
|
|
||||||
embed.setDescription(description);
|
|
||||||
|
|
||||||
embeds.push(embed);
|
|
||||||
}
|
|
||||||
|
|
||||||
const pagination = new Pagination(interaction);
|
|
||||||
pagination.setEmbeds(embeds, (embed, index, array) => {
|
|
||||||
const footerText = [
|
|
||||||
`${index + 1}/${array.length}`,
|
|
||||||
embed.data.footer.text
|
|
||||||
].filter(notEmpty).join(' · ')
|
|
||||||
return embed.setFooter({ text: footerText });
|
|
||||||
});
|
|
||||||
pagination.render();
|
|
||||||
}
|
|
||||||
}
|
|
90
src/commands/utility/file.js
Normal file
90
src/commands/utility/file.js
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder, EmbedBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
|
||||||
|
const { readFileSync } = require("node:fs");
|
||||||
|
const { stringify } = require("node:querystring");
|
||||||
|
const { Pagination } = require("pagination.djs");
|
||||||
|
|
||||||
|
const data = new SlashCommandBuilder()
|
||||||
|
.setName("file")
|
||||||
|
.setDescription("SearxNG-powered file search")
|
||||||
|
.addStringOption(builder =>
|
||||||
|
builder //
|
||||||
|
.setName("query")
|
||||||
|
.setRequired(true)
|
||||||
|
.setDescription("What to search for")
|
||||||
|
)
|
||||||
|
.setContexts([
|
||||||
|
InteractionContextType.Guild,
|
||||||
|
InteractionContextType.BotDM,
|
||||||
|
InteractionContextType.PrivateChannel
|
||||||
|
])
|
||||||
|
.setIntegrationTypes([
|
||||||
|
ApplicationIntegrationType.GuildInstall,
|
||||||
|
ApplicationIntegrationType.UserInstall
|
||||||
|
]);
|
||||||
|
|
||||||
|
function notEmpty(str) {
|
||||||
|
return str && str.trim() !== ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const emojis = JSON.parse(readFileSync("config/emojis.json"));
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data,
|
||||||
|
async execute(interaction) {
|
||||||
|
const query = interaction.options.getString("query");
|
||||||
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
var queryString = stringify({
|
||||||
|
"categories": "files",
|
||||||
|
"format": "json",
|
||||||
|
"q": query
|
||||||
|
});
|
||||||
|
|
||||||
|
const embeds = [];
|
||||||
|
const data = await (await fetch(`${process.env.SEARXNG_INSTANCE}/search?${queryString}`)).json();
|
||||||
|
for (const result of data.results) {
|
||||||
|
if (result.magnetlink) result.magnetlink = `[magnet](${process.env.BASE_URL}/magnet/${result.magnetlink})`;
|
||||||
|
|
||||||
|
const footerText = ([
|
||||||
|
result.filesize,
|
||||||
|
`${result.seed} S`,
|
||||||
|
`${result.leech} L`
|
||||||
|
]).filter(notEmpty).join(" • ");
|
||||||
|
|
||||||
|
const site = result.parsed_url.slice(0, 2).join("://");
|
||||||
|
|
||||||
|
const description = [
|
||||||
|
"Downloads:",
|
||||||
|
result.magnetlink,
|
||||||
|
result.torrentfile,
|
||||||
|
result.url
|
||||||
|
].filter(notEmpty).join("\n");
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setAuthor({
|
||||||
|
name: result.engine,
|
||||||
|
iconURL: `https://vault.incest.world/icons/${result.parsed_url[1]}/icon.png`
|
||||||
|
})
|
||||||
|
.setTitle(result.title)
|
||||||
|
.setURL(result.url)
|
||||||
|
.setColor("#cba6f7")
|
||||||
|
.setDescription(description)
|
||||||
|
.setFooter({
|
||||||
|
text: footerText
|
||||||
|
})
|
||||||
|
.setTimestamp(new Date(result.publishedDate));
|
||||||
|
|
||||||
|
embeds.push(embed);
|
||||||
|
}
|
||||||
|
|
||||||
|
const pagination = new Pagination(interaction);
|
||||||
|
pagination.setEmbeds(embeds, (embed, index, array) => {
|
||||||
|
const footerText = [
|
||||||
|
`${index + 1}/${array.length}`,
|
||||||
|
embed.data.footer.text
|
||||||
|
].filter(notEmpty).join(' • ')
|
||||||
|
return embed.setFooter({ text: footerText });
|
||||||
|
});
|
||||||
|
pagination.render();
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,8 @@ for (const folder of commandFolders) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client.on(Events.InteractionCreate, async interaction => {
|
client.on(Events.InteractionCreate, async interaction => {
|
||||||
|
if (!interaction.isAutocomplete() && !interaction.isCommand()) return;
|
||||||
|
|
||||||
const command = interaction.client.commands.get(interaction.commandName);
|
const command = interaction.client.commands.get(interaction.commandName);
|
||||||
if (!command) {
|
if (!command) {
|
||||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||||
|
|
|
@ -36,7 +36,13 @@ app.get("/view/:paste", async function (req, res) {
|
||||||
bot,
|
bot,
|
||||||
text
|
text
|
||||||
});
|
});
|
||||||
return;
|
});
|
||||||
|
|
||||||
|
app.get("/magnet/:magnet", function (req, res) {
|
||||||
|
res.render("magnet", {
|
||||||
|
bot,
|
||||||
|
url: (req.params.magnet + (req.originalUrl.includes("?") ? req.originalUrl.slice(req.originalUrl.indexOf("?")) : '')).replaceAll('"', '"')
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.all('*', function (req, res) {
|
app.all('*', function (req, res) {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<head><% invite = `https://discord.com/oauth2/authorize?client_id=${bot.user.id}&scope=applications.commands&integration_type=` %>
|
<meta charset="UTF-8"><% invite = `https://discord.com/oauth2/authorize?client_id=${bot.user.id}&scope=applications.commands&integration_type=` %>
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"><% for(let i = 16; i <= 512; i*=2) { %>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"><% for(let i = 16; i <= 512; i*=2) { %>
|
||||||
<link rel="shortcut icon" href="<%- bot.user.avatarURL({ size: i, forceStatic: true }) %>" sizes="<%-i%>x<%-i%>"><% } %>
|
<link rel="shortcut icon" href="<%- bot.user.avatarURL({ size: i, forceStatic: true }) %>" sizes="<%-i%>x<%-i%>"><% } %>
|
||||||
<title><%- (typeof(title) != "undefined" ? title : bot.user.username) %></title>
|
<title><%- (typeof(title) != "undefined" ? title : bot.user.username) %></title>
|
||||||
<link rel="stylesheet" href="/bs/css/bootstrap.min.css">
|
<link rel="stylesheet" href="/bs/css/bootstrap.min.css">
|
||||||
<script src="/bs/js/bootstrap.min.js"></script>
|
<script src="/bs/js/bootstrap.min.js"></script>
|
||||||
</head>
|
|
|
@ -1,7 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
<%- include("../partials/head.ejs"); %>
|
<%- include("../partials/head.ejs"); %>
|
||||||
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<%- include("../partials/header.ejs"); %>
|
<%- include("../partials/header.ejs"); %>
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
<%- include("../partials/head.ejs"); %>
|
<%- include("../partials/head.ejs"); %>
|
||||||
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<%- include("../partials/header.ejs"); %>
|
<%- include("../partials/header.ejs"); %>
|
||||||
|
|
18
src/server/views/magnet.ejs
Normal file
18
src/server/views/magnet.ejs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<%- include("../partials/head.ejs"); %>
|
||||||
|
<meta http-equiv="refresh" content="5; url=<%-url%>">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<%- include("../partials/header.ejs"); %>
|
||||||
|
<div class="container">
|
||||||
|
<p>You should get redirected within 5 seconds.</p>
|
||||||
|
<a href="<%-url%>">Not redirected automatically?</a>
|
||||||
|
</div>
|
||||||
|
<%- include("../partials/footer.ejs"); %>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -1,7 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
<%- include("../partials/head.ejs"); %>
|
<%- include("../partials/head.ejs"); %>
|
||||||
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<%- include("../partials/header.ejs"); %>
|
<%- include("../partials/header.ejs"); %>
|
||||||
|
|
Loading…
Reference in a new issue