From a5a1ef55e913b3f4c9d0b6d1b2d07dd7ba5474f1 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 24 Dec 2021 01:52:31 -0700 Subject: [PATCH] shortened charsearch toggleable --- commands/anime/char.js | 6 +++--- util/anime/charsearch.js | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/commands/anime/char.js b/commands/anime/char.js index 5624799..0413423 100644 --- a/commands/anime/char.js +++ b/commands/anime/char.js @@ -246,7 +246,7 @@ module.exports = { if (!tempchar) {return;} args = tempchar.split(/\s+/g); } - let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700); + let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700, 0); let fn; if (asr === 0) { return message.channel.send("That search returned no results! Try again?"); @@ -311,7 +311,7 @@ module.exports = { if (!tempchar) {return;} args = tempchar.split(/\s+/g); } - let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700); + let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700, 0); let fn; if (asr === 0) { return message.channel.send("That search returned no results! Try again?"); @@ -477,7 +477,7 @@ module.exports = { if (!tempchar) {return;} args = tempchar.split(/\s+/g); } - let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700); + let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700, 0); let fn; if (asr === 0) { return message.channel.send("That search returned no results! Try again?"); diff --git a/util/anime/charsearch.js b/util/anime/charsearch.js index d72ec35..adb4b65 100644 --- a/util/anime/charsearch.js +++ b/util/anime/charsearch.js @@ -6,24 +6,28 @@ const Char = require('../../models/char'); const {Pagination} = require("../../util/pagination"); -module.exports = async (message, client, search, threshold=-10000, type='top') => { +module.exports = async (message, client, search, threshold=-10000, type='full') => { let da = []; const me = async (char) => { if (da.includes(client.misc.cache.chars.get(char))) {return 0;} let cch = char.anime ? char : await Char.findOne({id: client.misc.cache.chars.get(char)}); let ani = await Ani.findOne({id: cch.anime}); let forceAni = false; if (!ani) {forceAni = true;} - da.push(cch.id); - return {embed: new Discord.MessageEmbed() + let rte = new Discord.MessageEmbed() .setTitle(cch.name) .setAuthor('Character Search', message.author.avatarURL()) .setDescription(`**Name:** ${cch.name}`) .addField('Other', `**Anime**: ${forceAni ? cch.anime : `${ani.name} | ${ani.japname} | \`${ani.id}\``}\n\n**Gender**: ${cch.gender}\n`) - .addField("Loved by", `**${cch.loved}** Natsuki user${cch.loved === 1 ? '' : 's'}!\n\`char love ${cch.name}\``) .setColor("c375f0") .setImage(cch.thumbnail) .setFooter('Natsuki', client.user.avatarURL()) - .setTimestamp(), id: cch.id}; + .setTimestamp(); + if (type === 'full') { + rte.addField("Loved by", `**${cch.loved}** Natsuki user${cch.loved === 1 ? '' : 's'}!\n\`char love ${cch.name}\``); + if (cch.nicknames.length) {rte.addField("Nicknames/Other Names", cch.nicknames.join(", "));} + } + da.push(cch.id); + return {embed: rte, id: cch.id}; }; let attF = await Char.findOne({id: search.trim().toLowerCase()});