shortened charsearch toggleable

master
Kit Kasune 3 years ago
parent 57dfc824a0
commit a5a1ef55e9
  1. 6
      commands/anime/char.js
  2. 14
      util/anime/charsearch.js

@ -246,7 +246,7 @@ module.exports = {
if (!tempchar) {return;} if (!tempchar) {return;}
args = tempchar.split(/\s+/g); 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; let fn;
if (asr === 0) { if (asr === 0) {
return message.channel.send("That search returned no results! Try again?"); return message.channel.send("That search returned no results! Try again?");
@ -311,7 +311,7 @@ module.exports = {
if (!tempchar) {return;} if (!tempchar) {return;}
args = tempchar.split(/\s+/g); 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; let fn;
if (asr === 0) { if (asr === 0) {
return message.channel.send("That search returned no results! Try again?"); return message.channel.send("That search returned no results! Try again?");
@ -477,7 +477,7 @@ module.exports = {
if (!tempchar) {return;} if (!tempchar) {return;}
args = tempchar.split(/\s+/g); 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; let fn;
if (asr === 0) { if (asr === 0) {
return message.channel.send("That search returned no results! Try again?"); return message.channel.send("That search returned no results! Try again?");

@ -6,24 +6,28 @@ const Char = require('../../models/char');
const {Pagination} = require("../../util/pagination"); 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 = []; let da = [];
const me = async (char) => { const me = async (char) => {
if (da.includes(client.misc.cache.chars.get(char))) {return 0;} 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 cch = char.anime ? char : await Char.findOne({id: client.misc.cache.chars.get(char)});
let ani = await Ani.findOne({id: cch.anime}); let ani = await Ani.findOne({id: cch.anime});
let forceAni = false; if (!ani) {forceAni = true;} let forceAni = false; if (!ani) {forceAni = true;}
da.push(cch.id); let rte = new Discord.MessageEmbed()
return {embed: new Discord.MessageEmbed()
.setTitle(cch.name) .setTitle(cch.name)
.setAuthor('Character Search', message.author.avatarURL()) .setAuthor('Character Search', message.author.avatarURL())
.setDescription(`**Name:** ${cch.name}`) .setDescription(`**Name:** ${cch.name}`)
.addField('Other', `**Anime**: ${forceAni ? cch.anime : `${ani.name} | ${ani.japname} | \`${ani.id}\``}\n\n**Gender**: ${cch.gender}\n`) .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") .setColor("c375f0")
.setImage(cch.thumbnail) .setImage(cch.thumbnail)
.setFooter('Natsuki', client.user.avatarURL()) .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()}); let attF = await Char.findOne({id: search.trim().toLowerCase()});

Loading…
Cancel
Save