From b84f18024832725677499fad719d8438074ecd2d Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 24 Dec 2021 18:16:40 -0700 Subject: [PATCH] better snippet, rand image on char view --- .vscode/discordjs.code-snippets | 4 ++-- commands/anime/charimage.js | 2 +- util/anime/charsearch.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.vscode/discordjs.code-snippets b/.vscode/discordjs.code-snippets index 98fbce6..7bb8814 100644 --- a/.vscode/discordjs.code-snippets +++ b/.vscode/discordjs.code-snippets @@ -10,7 +10,7 @@ "scope": "javascript,typescript", "prefix": "djscmd", "body": [ - "const Discord = require('discord.js');${1:\n${2:\n}const $3 = require(\"$4\");\n}", + "const Discord = require('discord.js');${1:\n${2:\n}const $3 = require(\"$4\");}\n", "module.exports = {", " name: \"$5\",", " aliases: [$6],", @@ -19,7 +19,7 @@ " description: \"$8\",", " syntax: '`$9`',", " extra: ${10:null}${11:,\n guildOnly: true}", - " },${12:\n cooldown: {\n time: $13,\n silent: ${14|true,false|}${15:,\n message: \"$16\"\\}},}", + " },${12:\n cooldown: {\n time: $13,\n silent: ${14|true,false|}${15:,\n message: \"$16\"}\n \\},}", " help: new Discord.MessageEmbed()", " .setTitle(\"Help -> $17\")", " .setDescription(\"$18\")${19:\n .addField(\"$20\", \"$21\")}", diff --git a/commands/anime/charimage.js b/commands/anime/charimage.js index 6059c63..51b73b3 100644 --- a/commands/anime/charimage.js +++ b/commands/anime/charimage.js @@ -59,7 +59,7 @@ module.exports = { let ch = await Char.findOne({id: fn}); if (list) { - let pages = ch.images.map(im => new Discord.MessageEmbed() + let pages = ch.images.push(ch.thumbnail).map(im => new Discord.MessageEmbed() .setTitle(ch.name) .setDescription(`**Name:** ${ch.name}`) .addField('Other', `**Anime**: ${client.misc.cache.animeID.get(ch.anime)}\n\n**Gender**: ${ch.gender}\n`) diff --git a/util/anime/charsearch.js b/util/anime/charsearch.js index adb4b65..f240cb8 100644 --- a/util/anime/charsearch.js +++ b/util/anime/charsearch.js @@ -13,13 +13,14 @@ 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;} + cch.images.push(cch.thumbnail); let rte = new Discord.MessageEmbed() .setTitle(cch.name) .setAuthor('Character Search', message.author.avatarURL()) .setDescription(`**Name:** ${cch.name}`) .addField('Other', `**Anime**: ${forceAni ? cch.anime : `${ani.name} | ${ani.japname} | \`${ani.id}\``}\n\n**Gender**: ${cch.gender}\n`) .setColor("c375f0") - .setImage(cch.thumbnail) + .setImage(cch.images[Math.floor(Math.random() * (cch.images.length + 1))]) .setFooter('Natsuki', client.user.avatarURL()) .setTimestamp(); if (type === 'full') {