re-add nsfw

This commit is contained in:
Ashley Graves 2024-10-10 11:19:08 +02:00
parent ba50f40868
commit 43a3fe4c25

View file

@ -56,14 +56,14 @@ function notEmpty(str) {
const regexCutTags = /[\S\s]{1,75}[^,]{0,25}/;
function formatTags(tags) {
const tagString = decode(tags.join(', '))
const tagString = decode(tags.join(', '));
if (tagString.length < 100) {
return tagString
return tagString;
}
const tagCutMatch = tagString.match(regexCutTags) ?? []
return `${escapeMarkdown(tagCutMatch[0] ?? '')}...`
const tagCutMatch = tagString.match(regexCutTags) ?? [];
return `${escapeMarkdown(tagCutMatch[0] ?? '')}, ...`;
}
const ratingEmojis = {
@ -88,10 +88,6 @@ function formatScore(score) {
}
}
function isNSFWPost(post) {
return !['s', 'g'].includes(post.rating)
}
function formatTime(time) {
return `${(Number(time) / 1e6).toFixed(2)}ms`
}
@ -114,16 +110,16 @@ module.exports = {
const booru = interaction.options.getString("booru") ?? defaultBooru;
const nsfw = interaction.options.getBoolean("nsfw") ?? false;
//await interaction.deferReply();
console.log(booru, tags);
await interaction.reply("Searching, please wait...");
tags = [...(nsfw ? [] : ["-rating:explicit", "-rating:questionable"]), ...tags];
const startTime = process.hrtime.bigint();
var post = null;
while (post == null) {
var newPost = (await Booru.search(booru, ["-rating:explicit", ...tags], { limit: 1, random: true, credentials: credentials[booru] ?? null }))[0];
var newPost = (await Booru.search(booru, tags, { limit: 1, random: true, credentials: credentials[booru] ?? null }))[0];
if (newPost == null) {
await interaction.reply("Could not find any post matching tags.");
await interaction.editReply("Could not find any post matching tags.");
return;
}
if (/*!nsfw && isNSFWPost(newPost) || */isAIPost(newPost)) continue;
@ -177,9 +173,9 @@ module.exports = {
iconURL: `https://${post.booru.domain}/favicon.ico`,
})
await interaction.reply({ embeds: [embed.data] });
await interaction.editReply({ embeds: [embed.data] });
} else {
await interaction.reply(
await interaction.editReply(
'>>> ' + bold(`[Post #${post.id}](<${post.postView}>)`) + "\n" +
description + "\n" +
footerText