list characters in anime

master
Kit Kasune 3 years ago
parent 3fd08ad2f5
commit 8a12728c99
  1. 60
      commands/anime/char.js
  2. 5
      util/anime/anisearch.js

@ -283,7 +283,7 @@ module.exports = {
return message.channel.send(`I've added **${tfc.name}** to your loved/favorited character list!`); return message.channel.send(`I've added **${tfc.name}** to your loved/favorited character list!`);
} }
if (['loved', 'favorites', 'favs'].includes(args[0].toLowerCase())) { if (['loved', 'favorites', 'favs', 'ls', 'fs'].includes(args[0].toLowerCase())) {
let cf = await CF.findOne({uid: mention ? mention.id : message.author.id}); let cf = await CF.findOne({uid: mention ? mention.id : message.author.id});
if (!cf || !cf.loved.length) {return message.channel.send(`Looks like ${mention ? 'they' : 'you'} haven't favorited any characters!`);} if (!cf || !cf.loved.length) {return message.channel.send(`Looks like ${mention ? 'they' : 'you'} haven't favorited any characters!`);}
let chars = cf.loved; let chars = cf.loved;
@ -369,6 +369,64 @@ module.exports = {
return message.channel.send(`Character image ${queue ? "submitted" : "added"}.`); return message.channel.send(`Character image ${queue ? "submitted" : "added"}.`);
} }
if (['la', 'listani', 'listanime', 'inani', 'inanime', 'ia'].includes(args[0].toLowerCase())) {
args.shift();
let paginate = args[0] && args[0].toLowerCase() === 'paginate';
if (paginate) {args.shift();}
if (!args[0]) {
let tempchar = await ask(message, "What anime would you like to view the characters of?", 60000, false, true);
if (!tempchar) {return;}
args = tempchar.split(/\s+/g);
}
let asr = await ans(message, client, args.join(" ").toLowerCase(), undefined, 0);
let fn;
if (asr === 0) {
return message.channel.send("That search returned no results! Try again?");
} else if (asr instanceof Pagination) {
await asr.start({user: message.author.id, startPage: 1, endTime: 60000});
await asr.message.react('✅');
await message.channel.send("React with :white_check_mark: when you've found the anime you want!");
let arc;
try {arc = await asr.message.awaitReactions({filter: (r) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});}
catch {return message.reply("Looks like you didn't find the anime you were looking for.");}
let collected = arc.first().emoji.name;
if (collected === '✅') {
fn = client.misc.cache.chars.get(asr.getCurrentPage().title.trim());
asr.stop();
}
else {return message.reply("Looks like you didn't find the anime you were looking for.");}
} else {fn = asr.id;}
let anime = await AniData.findOne({id: fn});
if (!anime) {return message.channel.send("Huh... even though I knew exactly what anime you were looking for, I scoured my endless tomes of knowledge and couldn't find it. I would definitely talk to my devs.");}
if (paginate) {
let chs = [];
anime.characters.forEach(ch => chs.push(Char.findOne({id: ch})));
chs = await Promise.all(chs);
let pages = [];
chs.forEach(ch => pages.push( new Discord.MessageEmbed()
.setTitle(ch.name)
.setDescription(`**Name:** ${ch.name}`)
.addField('Other', `**Anime**: ${`${anime.name} | ${anime.japname} | \`${anime.id}\``}\n\n**Gender**: ${ch.gender}\n`)
.addField("Loved by", `**${ch.loved}** Natsuki user${ch.loved === 1 ? '' : 's'}!\n\`${prefix}char love ${ch.name}\``)
.setColor("c375f0")
.setImage(ch.thumbnail)
.setFooter('Natsuki', client.user.avatarURL())
.setTimestamp()
));
let pag = new Pagination(message.channel, pages, message, client, true);
return await pag.start({user: message.author.id, endTime: 60000});
} else {
return message.channel.send({embeds: [
new Discord.MessageEmbed()
.setTitle(`${anime.name}: Characters`)
.setThumbnail(anime.thumbnail)
.setDescription(anime.characters.map(ch => client.misc.cache.charsID.get(ch)).join(", "))
.setFooter("Natsuki", client.user.avatarURL())
.setTimestamp()
]});
}
}
return message.channel.send(`Invalid arg! Syntax: \`${prefix}char <add|view|search|random|love|loved>\``); return message.channel.send(`Invalid arg! Syntax: \`${prefix}char <add|view|search|random|love|loved>\``);
} }
}; };

@ -2,7 +2,6 @@ const fz = require('fuzzysort');
const Discord = require('discord.js'); const Discord = require('discord.js');
const Ani = require('../../models/anime'); const Ani = require('../../models/anime');
const Char = require('../../models/char');
const {Pagination} = require("../../util/pagination"); const {Pagination} = require("../../util/pagination");
@ -11,7 +10,6 @@ module.exports = async (message, client, search, threshold=-10000, type='full')
const me = async (ani) => { const me = async (ani) => {
if (da.includes(client.misc.cache.anime.get(ani))) {return 0;} if (da.includes(client.misc.cache.anime.get(ani))) {return 0;}
let an = ani.plot ? ani : await Ani.findOne({id: client.misc.cache.anime.get(ani)}); let an = ani.plot ? ani : await Ani.findOne({id: client.misc.cache.anime.get(ani)});
let chs = [];
let rte = new Discord.MessageEmbed() let rte = new Discord.MessageEmbed()
.setTitle(an.name) .setTitle(an.name)
.setAuthor('Anime Search', message.author.avatarURL()) .setAuthor('Anime Search', message.author.avatarURL())
@ -25,7 +23,8 @@ module.exports = async (message, client, search, threshold=-10000, type='full')
.addField('Description', an.plot) .addField('Description', an.plot)
.addField('Length', `**# of Seasons:** ${an.seasons}\n**# of Episodes:** ${an.episodes}`) .addField('Length', `**# of Seasons:** ${an.seasons}\n**# of Episodes:** ${an.episodes}`)
.addField('Airing', `**Began:** ${an.airStartDate}\n**Ended:** ${an.isComplete ? an.airEndDate : 'This anime is still airing!'}`) .addField('Airing', `**Began:** ${an.airStartDate}\n**Ended:** ${an.isComplete ? an.airEndDate : 'This anime is still airing!'}`)
.addField('Other', `**Genre(s):** ${an.genres.join(", ")}\n**Tags:** ${an.tags.join(", ")}\n**Characters:** ${an.characters.map(char => client.misc.cache.charsID.get(char)).join(', ')}\n**Stream this at:** ${an.streamAt.join(", ")}`) .addField("Cast", `**${an.characters.length} Characters**\n${an.characters.map(char => client.misc.cache.charsID.get(char)).join(', ')}`)
.addField('Other', `**Genre(s):** ${an.genres.join(", ")}\n**Tags:** ${an.tags.join(", ")}\n**Stream this at:** ${an.streamAt.join(", ")}`)
} }
da.push(an.id); da.push(an.id);
return {embed: rte, id: an.id}; return {embed: rte, id: an.id};

Loading…
Cancel
Save