Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use desc if available, use mod effect if available #395

Merged
merged 2 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/commands/Ondemand/Mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.```';
}

Expand All @@ -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"
const url = `${apiBase}/mods/search/${query.toLowerCase()}`;
const results = await fetch(url);
if (results.length > 0) {
const pages = [];
results.forEach((result) => {
Expand Down
14 changes: 13 additions & 1 deletion src/embeds/ModEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ 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
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, '_')}`;
this.image = {
url: `https://cdn.warframestat.us/img/${modData.imageName}`,
Expand Down