wayy more efficient anisearch

master
Kit Kasune 3 years ago
parent 50a27b5435
commit 2562a9c71f
  1. 2
      .idea/discord.xml
  2. 31
      .idea/workspace.xml
  3. 4
      commands/anime/anime.js
  4. 11
      commands/anime/char.js
  5. 6
      util/anime/anisearch.js

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="DiscordProjectSettings"> <component name="DiscordProjectSettings">
<option name="show" value="ASK" /> <option name="show" value="PROJECT_FILES" />
<option name="description" value="" /> <option name="description" value="" />
</component> </component>
</project> </project>

@ -5,16 +5,11 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment=""> <list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.name" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/Natsuki.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/Natsuki.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/discord.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/discord.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/discord.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/discord.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/handle/command.js" beforeDir="false" afterPath="$PROJECT_DIR$/handle/command.js" afterDir="false" /> <change beforePath="$PROJECT_DIR$/commands/anime/anime.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/anime/anime.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" /> <change beforePath="$PROJECT_DIR$/commands/anime/char.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/anime/char.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" /> <change beforePath="$PROJECT_DIR$/util/anime/anisearch.js" beforeDir="false" afterPath="$PROJECT_DIR$/util/anime/anisearch.js" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -24,6 +19,17 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="GitSEFilterConfiguration">
<file-type-list>
<filtered-out-file-type name="LOCAL_BRANCH" />
<filtered-out-file-type name="REMOTE_BRANCH" />
<filtered-out-file-type name="TAG" />
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list>
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="1wWIAa3TuwhYwX0w4tzIs42s0ZG" /> <component name="ProjectId" id="1wWIAa3TuwhYwX0w4tzIs42s0ZG" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
@ -34,14 +40,16 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" /> <property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" /> <property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.selected.package.eslint" value="(autodetect)" /> <property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" /> <property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="nodejs_package_manager_path" value="npm" /> <property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="vue.rearranger.settings.migration" value="true" /> <property name="vue.rearranger.settings.migration" value="true" />
</component> </component>
<component name="RunManager" selected="Node.js.bot.js (1)"> <component name="RunManager" selected="Node.js.bot.js">
<configuration name="bot.js (1)" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/../Natsukiv13/bot.js" working-dir="$PROJECT_DIR$/../Natsukiv13"> <configuration name="bot.js (1)" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/../Natsukiv13/bot.js" working-dir="$PROJECT_DIR$/../Natsukiv13">
<method v="2" /> <method v="2" />
</configuration> </configuration>
@ -50,8 +58,8 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Node.js.bot.js (1)" />
<item itemvalue="Node.js.bot.js" /> <item itemvalue="Node.js.bot.js" />
<item itemvalue="Node.js.bot.js (1)" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
@ -65,6 +73,9 @@
<updated>1628567777733</updated> <updated>1628567777733</updated>
<workItem from="1628567780803" duration="1293000" /> <workItem from="1628567780803" duration="1293000" />
<workItem from="1628630503078" duration="47000" /> <workItem from="1628630503078" duration="47000" />
<workItem from="1640123242717" duration="910000" />
<workItem from="1640124257973" duration="3978000" />
<workItem from="1640131913922" duration="1135000" />
</task> </task>
<servers /> <servers />
</component> </component>

@ -80,7 +80,7 @@ module.exports = {
options.name = await ask(mesg, "What is the anime's name?", 60000, true); if (!options.name) {return;} options.name = await ask(mesg, "What is the anime's name?", 60000, true); if (!options.name) {return;}
if (options.name.length > 75) {clearDM(); return dmch.send("The anime name can't be more than 75 characters!");} if (options.name.length > 75) {clearDM(); return dmch.send("The anime name can't be more than 75 characters!");}
options.plot = await ask(mesg, "How would you describe the anime? Give a very brief description of things like its plot, main characters, and setting.", 240000, true); if (!options.plot) {return clearDM();;} options.plot = await ask(mesg, "How would you describe the anime? Give a very brief description of things like its plot, main characters, and setting.", 240000, true); if (!options.plot) {return clearDM();}
if (options.plot.length > 500) {clearDM(); return dmch.send("Oi! I said give a \"very brief\" description of the anime!");} if (options.plot.length > 500) {clearDM(); return dmch.send("Oi! I said give a \"very brief\" description of the anime!");}
options.japname = await ask(mesg, "What is the anime's japanese name? (The romanization, not the Japanese characters.)", 120000, true); if (!options.japname) {return clearDM();} options.japname = await ask(mesg, "What is the anime's japanese name? (The romanization, not the Japanese characters.)", 120000, true); if (!options.japname) {return clearDM();}
@ -259,7 +259,7 @@ module.exports = {
await asr.message.react('✅'); await asr.message.react('✅');
await message.channel.send("React with :white_check_mark: when you've found the anime you want!"); await message.channel.send("React with :white_check_mark: when you've found the anime you want!");
let arc; let arc;
try {arc = await asr.message.awaitReactions({filter: (r, u) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});} 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.");} catch {return message.reply("Looks like you didn't find the anime you were looking for.");}
collected = arc.first().emoji.name; collected = arc.first().emoji.name;
if (collected === '✅') { if (collected === '✅') {

@ -81,6 +81,7 @@ module.exports = {
if (options.anime.length > 75) {clearDM(); return dmch.send("The anime name can't be more than 75 characters!");} if (options.anime.length > 75) {clearDM(); return dmch.send("The anime name can't be more than 75 characters!");}
if (options.anime.trim().toLowerCase() === 'none') {options.anime = null;} if (options.anime.trim().toLowerCase() === 'none') {options.anime = null;}
else { else {
let fn;
let asr = await ans(mesg, client, options.anime.trim().toLowerCase()); let asr = await ans(mesg, client, options.anime.trim().toLowerCase());
if (asr === 0) { if (asr === 0) {
let conf = await ask(mesg, "That search returned no results. Would you like me to put the anime you specified down anyways? Otherwise, I'll abandon this process, and we can try again.", 60000, true); let conf = await ask(mesg, "That search returned no results. Would you like me to put the anime you specified down anyways? Otherwise, I'll abandon this process, and we can try again.", 60000, true);
@ -98,9 +99,9 @@ module.exports = {
await asr.message.react('✅'); await asr.message.react('✅');
await dmch.send("React with :white_check_mark: when you've found the anime you want!"); await dmch.send("React with :white_check_mark: when you've found the anime you want!");
let arc; let arc;
try {arc = await asr.message.awaitReactions({filter: (r, u) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});} try {arc = await asr.message.awaitReactions({filter: (r) => ['✅', '⏹'].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.");} 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; let collected = arc.first().emoji.name;
if (collected === '✅') { if (collected === '✅') {
fn = client.misc.cache.anime.get(asr.getCurrentPage().title.trim()); fn = client.misc.cache.anime.get(asr.getCurrentPage().title.trim());
asr.stop(); asr.stop();
@ -254,7 +255,7 @@ module.exports = {
await asr.message.react('✅'); await asr.message.react('✅');
await message.channel.send("React with :white_check_mark: when you've found the character you want!"); await message.channel.send("React with :white_check_mark: when you've found the character you want!");
let arc; let arc;
try {arc = await asr.message.awaitReactions({filter: (r, u) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});} 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 character you were looking for.");} catch {return message.reply("Looks like you didn't find the character you were looking for.");}
collected = arc.first().emoji.name; collected = arc.first().emoji.name;
if (collected === '✅') { if (collected === '✅') {
@ -314,7 +315,7 @@ module.exports = {
await asr.message.react('✅'); await asr.message.react('✅');
await message.channel.send("React with :white_check_mark: when you've found the character you want!"); await message.channel.send("React with :white_check_mark: when you've found the character you want!");
let arc; let arc;
try {arc = await asr.message.awaitReactions({filter: (r, u) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});} 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 character you were looking for.");} catch {return message.reply("Looks like you didn't find the character you were looking for.");}
collected = arc.first().emoji.name; collected = arc.first().emoji.name;
if (collected === '✅') { if (collected === '✅') {
@ -346,7 +347,7 @@ module.exports = {
args = tempchar.split(/\s+/g); args = tempchar.split(/\s+/g);
} }
let img = args.join(" "); let img = args.join(" ");
if (!img.match(/^https:\/\/(?:[\w\-].?)+[\/\w\-\%\(\)_]+\.(?:png|jpg|jpeg|gif|webp)$/gm)) {return message.channel.send("I don't think that's an image. Try again?");} if (!img.match(/^https:\/\/(?:[\w\-].?)+[\/\w\-%()_]+\.(?:png|jpg|jpeg|gif|webp)$/gm)) {return message.channel.send("I don't think that's an image. Try again?");}
if (!queue) { if (!queue) {
ch.images.push(img); ch.images.push(img);
ch.markModified('images'); ch.markModified('images');

@ -12,10 +12,6 @@ module.exports = async (message, client, search, threshold=-10000, type='full')
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 chs = [];
for (let i = 0; i < an.characters.length; i++) {
let tch = await Char.findOne({id: an.characters[i]});
if (tch) {chs.push(tch.name);}
}
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())
@ -29,7 +25,7 @@ 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:** ${chs.join(", ")}\n**Stream this at:** ${an.streamAt.join(", ")}`) .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(", ")}`)
} }
da.push(an.id); da.push(an.id);
return {embed: rte, id: an.id}; return {embed: rte, id: an.id};

Loading…
Cancel
Save