anime char overload prevention

master
Kit Kasune 3 years ago
parent 15c272e48e
commit 85c13d4545
  1. 6
      .gitignore
  2. 2
      .idea/Natsuki.iml
  3. 12
      .idea/workspace.xml
  4. 2
      commands/anime/char.js
  5. 2
      util/anime/anisearch.js
  6. 1
      util/anime/charsearch.js
  7. 5
      util/cache/char.js

6
.gitignore vendored

@ -2,4 +2,8 @@ node_modules/
config.json
auth.json
test.js
/.idea/
/.idea/
api/**/*
api/
.idea/**/*

@ -5,6 +5,8 @@
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/.idea/inspectionProfiles" />
<excludeFolder url="file://$MODULE_DIR$/api" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />

@ -4,10 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="extra images now show on char tag add">
<change afterPath="$PROJECT_DIR$/util/ts/livepagination.ts" afterDir="false" />
<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/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/ts/pagination.ts" beforeDir="false" afterPath="$PROJECT_DIR$/util/ts/pagination.ts" 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$/util/anime/anisearch.js" beforeDir="false" afterPath="$PROJECT_DIR$/util/anime/anisearch.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/anime/charsearch.js" beforeDir="false" afterPath="$PROJECT_DIR$/util/anime/charsearch.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/cache/char.js" beforeDir="false" afterPath="$PROJECT_DIR$/util/cache/char.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -64,6 +67,7 @@
<component name="RunAnythingCache">
<option name="myCommands">
<command value="npm run dev" />
<command value="git pull origin master" />
</option>
</component>
<component name="RunManager" selected="Node.js.bot.js">
@ -85,8 +89,8 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="npm.dev" />
<item itemvalue="Node.js.bot.js" />
<item itemvalue="npm.dev" />
<item itemvalue="Node.js.bot.js (1)" />
</list>
</recent_temporary>

@ -54,7 +54,7 @@ module.exports = {
if (message.attachments.size) {
if (options.thumbnail) {
if (!options.images) {options.images = [];}
Array.from(message.attachments.keys()).forEach(i => options.images.push(i));
Array.from(message.attachments.keys()).forEach(i => options.images.push(message.attachments.get(i).url));
} else {
if (!options.images) {options.images = [];}
let att = Array.from(message.attachments.keys());

@ -23,7 +23,7 @@ module.exports = async (message, client, search, threshold=-10000, type='full')
.addField('Description', an.plot)
.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("Cast", `**${an.characters.length} Characters**\n${an.characters.map(char => client.misc.cache.charsID.get(char)).join(', ')}`)
.addField("Cast", `**${an.characters.length} Characters**\n${(an.characters.length > 50 ? an.characters.slice(0, 49) : an.characters).map(char => client.misc.cache.charsID.get(char)).join(', ')}${an.characters.length > 50 ? `\n**+${an.characters.length - 50} Others**` : ''}`)
.addField('Other', `**Genre(s):** ${an.genres.join(", ")}\n**Tags:** ${an.tags.join(", ")}\n**Stream this at:** ${an.streamAt.join(", ")}${an.altNames && an.altNames.length ? `\n\n**Other names:** ${an.altNames.map(n => `\`${n}\``).join(', ')}` : ''}`)
.addField('Love', `**Watchers**: **${an.watchers} Natsuki ${client.utils.as(an.watchers, 'user')}** have this anime on their list of finished anime!\n\`n?watched ${an.name}\``)
}

@ -13,6 +13,7 @@ module.exports = async (message, client, search, threshold=-10000, type='full')
let cch = char.anime ? char : await Char.findOne({id: client.misc.cache.chars.get(char)});
let ani = await Ani.findOne({id: cch.anime});
let forceAni = false; if (!ani) {forceAni = true;}
//console.log(cch.images, cch.thumbnail);
cch.images.push(cch.thumbnail);
let rte = new Discord.MessageEmbed()
.setTitle(cch.name)

@ -20,6 +20,11 @@ module.exports = async (client, spinner) => {
client.misc.cache.charsID.set(char.id, char.name);
client.misc.cache.charsNum++;
client.misc.cache.charsLove.set(char.id, char.loved);
let hasNull = false;
char.images.forEach((image, index) => {
if (image === null) {char.images.splice(index, 1); hasNull = true;}
});
if (hasNull) {char.markModified('images'); await char.save();}
spinner.update({text: `${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${amount}`)} ${chalk.blueBright(`characters into lookup registry.`)} ${chalk.gray(`(${client.misc.cache.chars.size} // NN)`)}`});
amount++;
}

Loading…
Cancel
Save