re-add nsfw
This commit is contained in:
parent
ba50f40868
commit
43a3fe4c25
1 changed files with 10 additions and 14 deletions
|
@ -56,14 +56,14 @@ function notEmpty(str) {
|
||||||
|
|
||||||
const regexCutTags = /[\S\s]{1,75}[^,]{0,25}/;
|
const regexCutTags = /[\S\s]{1,75}[^,]{0,25}/;
|
||||||
function formatTags(tags) {
|
function formatTags(tags) {
|
||||||
const tagString = decode(tags.join(', '))
|
const tagString = decode(tags.join(', '));
|
||||||
|
|
||||||
if (tagString.length < 100) {
|
if (tagString.length < 100) {
|
||||||
return tagString
|
return tagString;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagCutMatch = tagString.match(regexCutTags) ?? []
|
const tagCutMatch = tagString.match(regexCutTags) ?? [];
|
||||||
return `${escapeMarkdown(tagCutMatch[0] ?? '')}...`
|
return `${escapeMarkdown(tagCutMatch[0] ?? '')}, ...`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ratingEmojis = {
|
const ratingEmojis = {
|
||||||
|
@ -88,10 +88,6 @@ function formatScore(score) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNSFWPost(post) {
|
|
||||||
return !['s', 'g'].includes(post.rating)
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(time) {
|
function formatTime(time) {
|
||||||
return `${(Number(time) / 1e6).toFixed(2)}ms`
|
return `${(Number(time) / 1e6).toFixed(2)}ms`
|
||||||
}
|
}
|
||||||
|
@ -114,16 +110,16 @@ module.exports = {
|
||||||
const booru = interaction.options.getString("booru") ?? defaultBooru;
|
const booru = interaction.options.getString("booru") ?? defaultBooru;
|
||||||
const nsfw = interaction.options.getBoolean("nsfw") ?? false;
|
const nsfw = interaction.options.getBoolean("nsfw") ?? false;
|
||||||
|
|
||||||
//await interaction.deferReply();
|
await interaction.reply("Searching, please wait...");
|
||||||
console.log(booru, tags);
|
tags = [...(nsfw ? [] : ["-rating:explicit", "-rating:questionable"]), ...tags];
|
||||||
|
|
||||||
const startTime = process.hrtime.bigint();
|
const startTime = process.hrtime.bigint();
|
||||||
|
|
||||||
var post = null;
|
var post = null;
|
||||||
while (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) {
|
if (newPost == null) {
|
||||||
await interaction.reply("Could not find any post matching tags.");
|
await interaction.editReply("Could not find any post matching tags.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (/*!nsfw && isNSFWPost(newPost) || */isAIPost(newPost)) continue;
|
if (/*!nsfw && isNSFWPost(newPost) || */isAIPost(newPost)) continue;
|
||||||
|
@ -177,9 +173,9 @@ module.exports = {
|
||||||
iconURL: `https://${post.booru.domain}/favicon.ico`,
|
iconURL: `https://${post.booru.domain}/favicon.ico`,
|
||||||
})
|
})
|
||||||
|
|
||||||
await interaction.reply({ embeds: [embed.data] });
|
await interaction.editReply({ embeds: [embed.data] });
|
||||||
} else {
|
} else {
|
||||||
await interaction.reply(
|
await interaction.editReply(
|
||||||
'>>> ' + bold(`[Post #${post.id}](<${post.postView}>)`) + "\n" +
|
'>>> ' + bold(`[Post #${post.id}](<${post.postView}>)`) + "\n" +
|
||||||
description + "\n" +
|
description + "\n" +
|
||||||
footerText
|
footerText
|
||||||
|
|
Loading…
Reference in a new issue