anime alt names

master
Kit Kasune 3 years ago
parent cf18c23ef5
commit df2731bf6d
  1. 58
      commands/anime/anime.js
  2. 1
      models/anime.js
  3. 1
      util/cache/anime.js

@ -285,5 +285,63 @@ module.exports = {
af.save(); af.save();
return message.channel.send(`I've added **${tfc.name}** to your list of finished animes!`); return message.channel.send(`I've added **${tfc.name}** to your list of finished animes!`);
} }
if (['nn', 'nickname', 'altname', 'nick', 'an'].includes(args[0].toLowerCase())) {
args.shift();
if (!args[0]) {
let tempchar = await ask(message, "What anime would you like to add to add an alternate name to?", 60000, false, true);
if (!tempchar) {return;}
args = tempchar.split(/\s+/g);
}
let asr = await ans(message, client, args.join(" ").trim().toLowerCase(), -700, 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.");}
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 tu = await UserData.findOne({uid: message.author.id});
let queue = false;
if (!tu || !tu.staff) {
message.channel.send("This alternate name will be __submitted__ for reviewal.");
queue = true;
}
let ch = await AniData.findOne({id: fn});
if (!ch.altNames) {ch.altNames = [];}
let nn = await ask(message, `What nickname would you like to add to ${ch.name}?`, 60000, false, true);
if (!nn) {return;}
if (ch.altNames.map(nickn => nickn.toLowerCase()).includes(nn.toLowerCase())) {return message.channel.send(`Looks like **${ch.name}** already has the nickname "${nn}".`);}
if (!queue) {
ch.altNames.push(nn);
ch.markModified('altNames');
ch.save();
client.misc.cache.anime.set(nn, ch.id);
}
client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({
embeds: [
new Discord.MessageEmbed()
.setAuthor({name: message.author.username, iconURL: message.author.avatarURL()})
.setTitle(`New Anime Alt Name ${queue ? "Submitted" : "Added"}`)
.setDescription(`For **${ch.name}** | \`${ch.id}\``)
.addField("Name", nn)
.setThumbnail(ch.thumbnail)
.setColor('c375f0')
.setTimestamp()
.setFooter({text: "Natsuki"})
], content: queue ? '<@330547934951112705>' : undefined
}).catch(() => {})).catch(() => {});
return message.channel.send(`Anime alt name ${queue ? "submitted" : "added"}.`);
}
} }
}; };

@ -15,6 +15,7 @@ const AniSchema = new mongoose.Schema({
genres: [String], genres: [String],
tags: {type: [String], default: []}, tags: {type: [String], default: []},
characters: [String], characters: [String],
altNames: {type: [String], default: []},
streamAt: [String], streamAt: [String],
watchers: {type: Number, default: 0}, watchers: {type: Number, default: 0},
listed: {type: Number, default: 0}, listed: {type: Number, default: 0},

@ -12,6 +12,7 @@ module.exports = async client => {
if (ani.queued !== true) { if (ani.queued !== true) {
client.misc.cache.anime.set(ani.japname, ani.id); client.misc.cache.anime.set(ani.japname, ani.id);
client.misc.cache.anime.set(ani.name, ani.id); client.misc.cache.anime.set(ani.name, ani.id);
if (ani.altNames) {ani.altNames.forEach(altName => client.misc.cache.anime.set(altName, ani.id));}
client.misc.cache.animeID.set(ani.id, ani.name); client.misc.cache.animeID.set(ani.id, ani.name);
client.misc.cache.animeLove.set(ani.id, ani.watchers); client.misc.cache.animeLove.set(ani.id, ani.watchers);
client.misc.cache.animeNum++; client.misc.cache.animeNum++;

Loading…
Cancel
Save