This commit is contained in:
Ashley Graves 2024-10-10 17:15:26 +02:00
parent 15ed1a8aab
commit 2bfaa4288e

View file

@ -14,7 +14,13 @@ for (const site of Object.keys(Booru.sites)) {
}) })
} }
const defaultBooru = "safebooru.org"; const defaultBooru = "gelbooru.com";
const ratings = [
"rating:general",
"rating:questionable",
"rating:sensitive",
"rating:explicit",
];
const data = new SlashCommandBuilder() const data = new SlashCommandBuilder()
.setName("booru") .setName("booru")
@ -25,10 +31,17 @@ const data = new SlashCommandBuilder()
.setRequired(true) .setRequired(true)
.setDescription("Tags to search for") .setDescription("Tags to search for")
) )
.addStringOption(builder =>
builder //
.setName("rating")
.setRequired(false)
.setDescription("Image rating (default: safe)")
.setChoices(ratings.map(r => { var x = r.split(":")[1]; var s = x[0].toUpperCase() + x.slice(1); return { name: s, value: r } }))
)
.addStringOption(builder => .addStringOption(builder =>
builder // builder //
.setName("booru") .setName("booru")
.setDescription("Booru board to search (default: safebooru.org)") .setDescription("Booru board to search (default: gelbooru.org)")
.addChoices(boorus) .addChoices(boorus)
) )
.setContexts([ .setContexts([
@ -114,24 +127,30 @@ function proxy(url) {
...auth ...auth
}); });
console.log(url);
return url; return url;
} }
module.exports = { module.exports = {
data, data,
async execute(interaction) { async execute(interaction) {
await interaction.deferReply();
const tags = (interaction.options.getString("tags") ?? "").split(" "); const tags = (interaction.options.getString("tags") ?? "").split(" ");
const containsBlacklist = tags.filter(i => blacklist.includes(i)); const containsBlacklist = tags.filter(i => blacklist.includes(i));
if (containsBlacklist.length > 0) { if (containsBlacklist.length > 0) {
await interaction.followUp(`<:warning:1293874152150667315> kill yourself.\n-# searched for blacklisted tag(s): \`${containsBlacklist.join(", ")}\``); await interaction.followUp(`searched for blacklisted tag(s): \`${containsBlacklist.join(", ")}\`.\n-# this incident will be reported.`);
var incidentChannel = interaction.client.channels.cache.get(process.env.INCIDENT_CHANNEL);
if (incidentChannel) {
incidentChannel.send(`User \`${interaction.user.username}\` (<@${interaction.user.id}>) searched for blacklisted tags:\n\`${containsBlacklist.join(", ")}\``);
}
return; return;
} }
const booru = interaction.options.getString("booru") ?? defaultBooru; const booru = interaction.options.getString("booru") ?? defaultBooru;
const rating = (interaction.options.getString("rating") ?? ratings[0]);
console.log(rating);
await interaction.deferReply(); const searchTags = [...tags, ...blacklist.map(i => "-" + i), ...ratings.filter(v => v != rating).map(i => "-" + i)];
const searchTags = [...tags, ...blacklist.map(i => "-" + i)]; console.log(rating, searchTags);
const startTime = process.hrtime.bigint(); const startTime = process.hrtime.bigint();