master
Kit Kasune 3 years ago
parent 9b00820287
commit 2329a206a1
  1. 45
      commands/anime/anime.js
  2. 8
      commands/anime/char.js
  3. 4
      util/anime/anisearch.js

@ -6,6 +6,8 @@ const AniData = require('../../models/anime');
const {TagFilter} = require("../../util/tagfilter");
const {Tag} = require ("../../util/tag");
const ask = require('../../util/ask');
const ans = require('../../util/anime/anisearch');
const {Pagination} = require('../../util/pagination');
module.exports = {
name: "anime",
@ -19,7 +21,7 @@ module.exports = {
let queue = false;
let options = {};
let dmch;
if (['a', 'add', 'n', 'new'].includes(args[0])) {
if (['a', 'add', 'n', 'new'].includes(args[0].trim().toLowerCase())) {
let tu = await UserData.findOne({uid: message.author.id});
if (!tu || !tu.staff) {
await message.channel.send("Since you aren't a Natsuki Staff member, this anime will be __submitted__ for reviewal!");
@ -142,11 +144,11 @@ module.exports = {
let amEmbed = new Discord.MessageEmbed()
.setTitle(`New Anime -> ${options.name}`)
.setDescription(`${queue ? 'Requested' : 'Added'} by ${message.author.tag}`)
.addField('Info', `**Name:** ${options.name}\n**Japanese Name:** ${options.japname}\n\n**Publishers:** ${foptions.publishers.join(", ")}\n**Studios:** ${foptions.studios.join(", ")}`)
.addField('Info', `**Name:** ${options.name}\n**Japanese Name:** ${options.japname}\n\n**Publishers:** ${foptions.publishers}\n**Studios:** ${foptions.studios}`)
.addField('Description', options.plot)
.addField('Length', `**# of Seasons:** ${options.seasons}\n**# of Episodes:** ${options.episodes}`)
.addField('Airing', `**Began:** ${options.airStartDate}\n**Ended:** ${options.isComplete ? options.airEndDate : 'This anime is still airing!'}`)
.addField('Other', `**Genre(s):** ${foptions.genres.join(", ")}\n**Tags:** ${foptions.tags.join(", ")}\n**Characters:** ${foptions.characters}\n**Stream this at:** ${foptions.streamAt}`)
.addField('Other', `**Genre(s):** ${foptions.genres}\n**Tags:** ${foptions.tags}\n**Characters:** ${foptions.characters}\n**Stream this at:** ${foptions.streamAt}`)
.setColor("c375f0")
.setImage(options.thumbnail)
.setFooter('Natsuki', client.user.avatarURL())
@ -160,10 +162,11 @@ module.exports = {
let rc = am.createReactionCollector({filter: (r, u) => ['👍', '👎'].includes(r.emoji.name) && u.id === message.author.id, max: 1, time: 60000});
rc.on("collect", async r => {
if (r.emoji.name !== '👎') {
while (true) {options.id = require('../../util/makeid')(4); if (!await AniData.findOne({id: options.id})) {break;}}
if (!queue) {amEmbed.addField("Reviewed", `Reviewed and submitted by <@${message.author.id}>`);}
else {amEmbed.addField("ID", options.id);}
amEmbed.setAuthor(!queue ? "Anime Added" : "Anime Submitted", message.author.avatarURL());
client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({embeds: [amEmbed]}));
while (true) {options.id = require('../../util/makeid')(4); if (!await AniData.findOne({id: options.id})) {break;}}
if (!queue) {options.queued = false;}
await new AniData(options).save();
return message.author.send(`Your anime has been ${!queue ? "added" : "submitted"}`);
@ -174,5 +177,39 @@ module.exports = {
rc.on("end", collected => {if (!collected.size) {return message.author.send("Looks like you ran out of time! Try again?");}});
} catch {return message.author.send("Hmm... there was some kind of error when I tried to submit that anime. Try again, and if it keeps not working, then go yell at my devs!");}
}
if (['s', 'search'].includes(args[0].trim().toLowerCase())) {
args.shift();
let asr = await ans(message, client, args.join(" ").trim().toLowerCase());
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});
} else {
await message.channel.send({embeds: [asr.embed]});
}
return;
}
if (['v', 'view'].includes(args[0].trim().toLowerCase())) {
args.shift();
let asr = await ans(message, client, args.join(" ").trim().toLowerCase(), -700);
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});
} else {
await message.channel.send({embeds: [asr.embed]});
}
return;
}
if (['reject'].includes(args[0].trim().toLowerCase())) {
let tu = await UserData.findOne({uid: message.author.id});
if (!tu || !tu.staff) {await message.channel.send("Since you aren't a Natsuki Staff member, you can't reject anime submissions!");}
let tr = await AniData.findOne({id: args[1].toLowerCase()});
if (!tr) {return message.reply("That anime submission doesn't seem to exist!");}
if (tr.queued !== true) {return message.reply("That anime was already accepted, so you can't reject it.");}
return await AniData.deleteOne({id: args[1].toLowerCase()})
.then(() => {return message.channel.send("I got that submission out of here!");})
.catch(() => {return message.reply("It seems that submission wasn't deleted for some reason. \*insert head scratching*");});
}
}
};

@ -99,7 +99,10 @@ module.exports = {
try {arc = await asr.message.awaitReactions({filter: (r, u) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});}
catch {return dmch.send("Looks like you didn't find the anime you were looking for, so I went ahead and ended the character creation for you.");}
collected = arc.first().emoji.name;
if (collected === '✅') {fn = client.misc.cache.anime.get(asr.getCurrentPage().title.trim());}
if (collected === '✅') {
fn = client.misc.cache.anime.get(asr.getCurrentPage().title.trim());
asr.stop();
}
else {return dmch.send("Looks like you didn't find the anime you were looking for, so I went ahead and ended the character creation for you.");}
} else {
await dmch.send({embeds: [asr.embed]});
@ -155,9 +158,10 @@ module.exports = {
let rc = am.createReactionCollector({filter: (r, u) => ['👍', '👎'].includes(r.emoji.name) && u.id === message.author.id, max: 1, time: 60000});
rc.on("collect", async r => {
if (r.emoji.name !== '👎') {
client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({embeds: [amEmbed]}));
if (!queue) {amEmbed.addField("Reviewed", `Reviewed and submitted by <@${message.author.id}>`);}
else {amEmbed.addField("ID", options.id);}
amEmbed.setAuthor(!queue ? "Character Added" : "Character Submitted", message.author.avatarURL());
client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({embeds: [amEmbed]}));
while (true) {options.id = require('../../util/makeid')(4); if (!await Char.findOne({id: options.id})) {break;}}
if (!queue) {options.queued = false;}
await new Char(options).save();

@ -5,7 +5,7 @@ const Ani = require('../../models/anime');
const {Pagination} = require("../../util/pagination");
module.exports = async (message, client, search, type='top') => {
module.exports = async (message, client, search, threshold=-10000, type='top') => {
const me = async (ani) => {
let an = await Ani.findOne({id: client.misc.cache.anime.get(ani)});
return {embed: new Discord.MessageEmbed()
@ -25,7 +25,7 @@ module.exports = async (message, client, search, type='top') => {
let attF = await Ani.findOne({id: search.trim().toLowerCase()});
if (attF) {return await me(res[0]);}
const res = fz.go(search, Array.from(client.misc.cache.anime.keys()), {limit: 10}).sort((a,b)=>a.score-b.score).map(k => k.target);
const res = fz.go(search, Array.from(client.misc.cache.anime.keys()), {threshold: threshold, limit: 10}).sort((a,b)=>a.score-b.score).map(k => k.target);
if (res.length === 0) {return 0;}
else if (res.length > 1) {
let tp = [];

Loading…
Cancel
Save