From ae760fb57a3c2b244feb968b65c81081c35f9ce5 Mon Sep 17 00:00:00 2001 From: Sunder Date: Mon, 5 Oct 2020 20:33:02 -0500 Subject: [PATCH 1/2] use desc if available, use mod effect if available --- src/commands/Ondemand/Mod.js | 7 +++++-- src/embeds/ModEmbed.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/commands/Ondemand/Mod.js b/src/commands/Ondemand/Mod.js index 545ad8281..93509f7ec 100644 --- a/src/commands/Ondemand/Mod.js +++ b/src/commands/Ondemand/Mod.js @@ -17,7 +17,8 @@ class Mod extends Command { */ constructor(bot) { super(bot, 'warframe.misc.mod', 'mod', 'Search the Warframe Wiki for a mod\'s image', 'WARFRAME'); - this.regex = new RegExp('^mod(.+)', 'i'); + // Should match "/mod blind rage, for example" + this.regex = new RegExp('^mod (.+)', 'i'); this.noResultStr = '```haskell\nNo result for search, Operator. Attempt another search query.```'; } @@ -35,7 +36,9 @@ class Mod extends Command { } try { - const results = await fetch(`${apiBase}/mods/search/${query}`); + // Need to search in all lower case. "Blind Rage = blind rage" + let url = `${apiBase}/mods/search/${query.toLowerCase()}`; + const results = await fetch(url); if (results.length > 0) { const pages = []; results.forEach((result) => { diff --git a/src/embeds/ModEmbed.js b/src/embeds/ModEmbed.js index 8f5f26889..d909d70de 100644 --- a/src/embeds/ModEmbed.js +++ b/src/embeds/ModEmbed.js @@ -18,7 +18,17 @@ class ModEmbed extends BaseEmbed { this.title = modData.name; this.color = rarity[modData.rarity.toLowerCase()]; - this.description = `_${emojify(modData.description)}_`; + + // If we have a description, show it. For stance mods, etc. + if (modData.description) { + this.description = `_${emojify(modData.description)}_`; + } + + // If we have an effect, show the max rank effect. Most mods, other than stances, should have this + if (modData.levelStats && modData.levelStats.length > 0) { + this.description = `_${emojify(modData.levelStats[modData.levelStats.length-1].stats.join('\n'))}_`; + } + this.url = `https://warframe.fandom.com/wiki/${modData.name.replace(/\s/ig, '_')}`; this.image = { url: `https://cdn.warframestat.us/img/${modData.imageName}`, From ee9c2ea9039ead8e1dbed7208260260274cfd6b9 Mon Sep 17 00:00:00 2001 From: Sunder Date: Mon, 5 Oct 2020 20:49:49 -0500 Subject: [PATCH 2/2] some linting --- src/commands/Ondemand/Mod.js | 2 +- src/embeds/ModEmbed.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commands/Ondemand/Mod.js b/src/commands/Ondemand/Mod.js index 93509f7ec..6c7a01275 100644 --- a/src/commands/Ondemand/Mod.js +++ b/src/commands/Ondemand/Mod.js @@ -37,7 +37,7 @@ class Mod extends Command { try { // Need to search in all lower case. "Blind Rage = blind rage" - let url = `${apiBase}/mods/search/${query.toLowerCase()}`; + const url = `${apiBase}/mods/search/${query.toLowerCase()}`; const results = await fetch(url); if (results.length > 0) { const pages = []; diff --git a/src/embeds/ModEmbed.js b/src/embeds/ModEmbed.js index d909d70de..ed685a678 100644 --- a/src/embeds/ModEmbed.js +++ b/src/embeds/ModEmbed.js @@ -18,15 +18,17 @@ class ModEmbed extends BaseEmbed { this.title = modData.name; this.color = rarity[modData.rarity.toLowerCase()]; - - // If we have a description, show it. For stance mods, etc. + + // If we have a description, show it. For stance mods, etc if (modData.description) { this.description = `_${emojify(modData.description)}_`; } - // If we have an effect, show the max rank effect. Most mods, other than stances, should have this - if (modData.levelStats && modData.levelStats.length > 0) { - this.description = `_${emojify(modData.levelStats[modData.levelStats.length-1].stats.join('\n'))}_`; + // If we have an effect, show the max rank effect + const statsLength = modData.levelStats.length; + if (modData.levelStats && statsLength > 0) { + const stats = modData.levelStats[statsLength - 1].stats.join('\n'); + this.description = `_${emojify(stats)}_`; } this.url = `https://warframe.fandom.com/wiki/${modData.name.replace(/\s/ig, '_')}`;