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()
.setName("booru")
@ -25,10 +31,17 @@ const data = new SlashCommandBuilder()
.setRequired(true)
.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 =>
builder //
.setName("booru")
.setDescription("Booru board to search (default: safebooru.org)")
.setDescription("Booru board to search (default: gelbooru.org)")
.addChoices(boorus)
)
.setContexts([
@ -114,24 +127,30 @@ function proxy(url) {
...auth
});
console.log(url);
return url;
}
module.exports = {
data,
async execute(interaction) {
await interaction.deferReply();
const tags = (interaction.options.getString("tags") ?? "").split(" ");
const containsBlacklist = tags.filter(i => blacklist.includes(i));
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;
}
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)];
const searchTags = [...tags, ...blacklist.map(i => "-" + i), ...ratings.filter(v => v != rating).map(i => "-" + i)];
console.log(rating, searchTags);
const startTime = process.hrtime.bigint();