Skip to content

Commit

Permalink
fix: asset migration to cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Oct 29, 2018
1 parent c87aed7 commit 5ad7ae8
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 32 deletions.
2 changes: 1 addition & 1 deletion commands.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/CommonFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const {
} = require('./resources/trackables.json');

const apiBase = process.env.API_BASE_PATH || 'https://api.warframestat.us';
const assetBase = process.env.ASSET_BASE_PATH || 'https://cdn.warframestat.us/genesis';
const wikiBase = process.env.WIKIA_BASE_PATH || 'https://warframe.fandom.com/wiki/';

const isVulgarCheck = new RegExp('(n[i!1]gg[e3]r|n[i!1]gg[ua]|h[i!1]tl[e3]r|n[a@]z[i!1]|[©ck]un[t7]|fu[©c]k|[©ck]umm?|f[a@4]g|d[i!1]ck|c[o0]ck|boner|sperm|gay|gooch|jizz|pussy|penis|r[i!1]mjob|schlong|slut|wank|whore|sh[i!1]t|sex|fuk|heil|p[o0]rn|pronz|suck|rape|scrotum)', 'ig');

Expand Down Expand Up @@ -576,4 +578,6 @@ module.exports = {
csvToCodes,
determineTweetType,
apiBase,
assetBase,
wikiBase,
};
5 changes: 4 additions & 1 deletion src/commands/Builds/AddBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

const Command = require('../../models/Command.js');
const BuildEmbed = require('../../embeds/BuildEmbed');
const { assetBase } = require('../CommonFunctions');

const outageThumb = `${assetBase}/img/outage.png`;

/**
* Create temporary voice/text channels (can be expanded in the future)
Expand Down Expand Up @@ -32,7 +35,7 @@ class AddBuild extends Command {
// save params based on order
const title = params[0] || 'My Build';
const body = params[1] || 'My Build Body';
const image = params[2] || 'https://i.imgur.com/31xCos6.png';
const image = params[2] || outageThumb;
const build = await this.settings.addNewBuild(title, body, image, message.author);
const embed = new BuildEmbed(this.bot, build);
this.messageManager.embed(message, embed, true, true);
Expand Down
7 changes: 4 additions & 3 deletions src/commands/Info/ItemEmbeddedInline.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ const Command = require('../../models/InlineCommand.js');
const FrameEmbed = require('../../embeds/FrameEmbed.js');
const WeaponEmbed = require('../../embeds/WeaponEmbed.js');
const WikiEmbed = require('../../embeds/WikiEmbed.js');
const { apiBase } = require('../../CommonFunctions');

const { apiBase, assetBase } = require('../../CommonFunctions');

const warframe = new Wikia('warframe');

const ancientRetributionThumb = `${assetBase}/img/ancient-retribution.png`;

const checkFrames = async (prompt) => {
const options = {
uri: `${apiBase}/warframes/search/${prompt}`,
Expand Down Expand Up @@ -59,7 +60,7 @@ const checkMods = async (prompt) => {
const [{ id }] = searchJson.items;
const detailsJson = await warframe.getArticleDetails({ ids: [id] });
let thumbUrl = detailsJson.items[`${id}`].thumbnail;
thumbUrl = thumbUrl ? thumbUrl.replace(/\/revision\/.*/, '') : 'https://i.imgur.com/11VCxbq.jpg';
thumbUrl = thumbUrl ? thumbUrl.replace(/\/revision\/.*/, '') : ancientRetributionThumb;
const list = await warframe.getArticlesList({ category: 'Mods', limit: 1000 });
let result;
list.items.forEach((item) => {
Expand Down
6 changes: 4 additions & 2 deletions src/commands/Ondemand/Damage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const Command = require('../../models/Command.js');
const { assetBase } = require('../CommonFunctions');

const damageChart = `${assetBase}/img/damage-chart.png`;

/**
* Displays the Damage 2.0 charts
Expand All @@ -12,7 +15,6 @@ class Damage extends Command {
*/
constructor(bot) {
super(bot, 'warframe.misc.damage', 'damage', 'Display Damage 2.0 chart');
this.damageChart = 'http://i.imgur.com/EOzr440.png';
}

/**
Expand All @@ -25,7 +27,7 @@ class Damage extends Command {
this.messageManager.embed(message, {
title: 'Legend',
image: {
url: 'http://i.imgur.com/EOzr440.png',
url: damageChart,
},
fields: [
{ name: 'Blast', value: '<:blast:363136256907149312>', inline: true },
Expand Down
6 changes: 4 additions & 2 deletions src/commands/Ondemand/Efficiency.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const Command = require('../../models/Command.js');
const { assetBase } = require('../CommonFunctions');

const efficiencyChart = `${assetBase}/img/efficiency-chart.png`;

/**
* Displays the Warframe efficincy/duration Chart
Expand All @@ -12,7 +15,6 @@ class Efficiency extends Command {
*/
constructor(bot) {
super(bot, 'warframe.misc.efficiency', 'efficiency', 'Display Warframe Efficiency Chart');
this.efficiencyChart = 'https://i.imgur.com/dT7lpW2.png';
}

/**
Expand All @@ -25,7 +27,7 @@ class Efficiency extends Command {
this.messageManager.sendFile(
message,
`Operator ${message.author.toString()}, the efficiency table, at your request.`,
this.efficiencyChart, 'efficiency.png', true,
efficiencyChart, 'efficiency.png', true,
);
return this.messageManager.statuses.SUCCESS;
}
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/AlertEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const alertThumb = `${assetBase}/img/alert.png`;

/**
* Generates alert embeds
Expand All @@ -15,7 +18,7 @@ class AlertEmbed extends BaseEmbed {
super();

this.thumbnail = {
url: 'http://i.imgur.com/KQ7f9l7.png',
url: alertThumb,
};
this.color = 0xF1C40F;
// compact
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/ConclaveChallengeEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const conclaveThumb = `${assetBase}/img/conclave-lg.png`;

const values = ['all', 'day', 'week'];

Expand Down Expand Up @@ -36,7 +39,7 @@ class ConclaveChallengeEmbed extends BaseEmbed {
}
this.title = `${platform ? `[${platform.toUpperCase()}] ` : ''}Current Challenges for category: ${category || 'none'}`;
this.thumbnail = {
url: 'http://i.imgur.com/KDzKPYA.png',
url: conclaveThumb,
};
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/DarvoEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const darvo = `${assetBase}/img/darvo-md.png`;

/**
* Generates daily deal embeds
Expand All @@ -17,7 +20,7 @@ class DarvoEmbed extends BaseEmbed {
this.color = 0x0000ff;
this.title = `[${platform.toUpperCase()}] Darvo Deal`;
this.thumbnail = {
url: 'http://i.imgur.com/UotylUm.png',
url: darvo,
};
this.fields = [
{
Expand Down
7 changes: 5 additions & 2 deletions src/embeds/EarthCycleEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

const BaseEmbed = require('./BaseEmbed.js');

const { timeDeltaToString, fromNow } = require('../CommonFunctions.js');
const { timeDeltaToString, fromNow, assetBase } = require('../CommonFunctions.js');

const ostron = `${assetBase}/img/ostron-banner.png`;
const earth = `${assetBase}/img/earth-planet.png`

/**
* Generates Earth cycle embeds
Expand All @@ -18,7 +21,7 @@ class EarthCycleEmbed extends BaseEmbed {
this.title = `Worldstate - ${state.isCetus ? 'Plains of Eidolon' : 'Earth'} Cycle - ${state.isDay ? 'Day' : 'Night'}time`;
this.color = state.isDay ? 0xB64624 : 0x000066;
this.thumbnail = {
url: state.isCetus ? 'https://i.imgur.com/Ph337PR.png' : 'https://i.imgur.com/oR6Sskf.png',
url: state.isCetus ? ostron : earth,
};
this.description = `Time remaining until ${state.isDay ? 'night' : 'day'}: ${timeDeltaToString(fromNow(new Date(state.expiry)))}`
+ `${state.bountyExpiry ? `\nBounties expire in ${timeDeltaToString(fromNow(new Date(state.bountyExpiry)))}` : ''}`;
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/EnemyEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const acolyteThumb = `${assetBase}/img/acolyte.png`;

/**
* Generates enemy embeds
Expand All @@ -15,7 +18,7 @@ class EnemyEmbed extends BaseEmbed {
super();

this.thumbnail = {
url: 'http://i.imgur.com/pMRt2Cp.png',
url: acolyteThumb,
};
this.title = `[${platform.toUpperCase()}] Acolytes`;
if (enemies.length > 1) {
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/EnhancementEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const arcaneThumb = `${assetBase}/img/arcane.png`;

const colors = {
common: 0x443B25,
Expand All @@ -21,7 +24,7 @@ class EnhancementEmbed extends BaseEmbed {
super();

this.thumbnail = {
url: 'https://i.imgur.com/tIBB0ea.png',
url: arcaneThumb,
};
if (enhancement && typeof enhancement !== 'undefined') {
this.title = enhancement.name;
Expand Down
9 changes: 6 additions & 3 deletions src/embeds/FissureEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase, wikiBase } = require('../CommonFunctions');

const fissureThumb = `${assetBase}img/fissure-sm.png`;

/**
* Generates fissure embeds
Expand All @@ -17,9 +20,9 @@ class FissureEmbed extends BaseEmbed {
if (fissures.length > 1) {
this.title = `[${platform.toUpperCase()}] Worldstate - Void Fissures`;
}
this.url = 'http://warframe.wikia.com/wiki/Void_Fissure';
this.url = `${wikiBase}Void_Fissure`;
this.thumbnail = {
url: 'http://i.imgur.com/EfIRu6v.png',
url: fissureThumb,
};
if (fissures.length > 1) {
fissures.sort((a, b) => a.tierNum - b.tierNum);
Expand All @@ -39,7 +42,7 @@ class FissureEmbed extends BaseEmbed {
this.description = `${f.node} against ${f.enemy}`;
this.footer.text = `${f.eta} remaining • Ends at `;
this.timestamp = new Date(f.expiry);
this.thumbnail.url = 'https://i.imgur.com/EfIRu6v.png';
this.thumbnail.url = fissureThumb;
}

this.color = 0x4aa1b2;
Expand Down
4 changes: 2 additions & 2 deletions src/embeds/FrameEmbed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { emojify } = require('../CommonFunctions.js');
const { emojify, assetBase } = require('../CommonFunctions');

/**
* Generates enemy embeds
Expand All @@ -16,7 +16,7 @@ class FrameEmbed extends BaseEmbed {
super();

this.thumbnail = {
url: 'https://i.imgur.com/tIBB0ea.png',
url: `${assetBase}/img/arcane.png`
};
if (frame && typeof frame !== 'undefined') {
this.title = frame.name;
Expand Down
7 changes: 5 additions & 2 deletions src/embeds/InvasionEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase, wikiBase } = require('../CommonFunctions');

const invasionThumb = `${assetBase}img/invasion.png`;

/**
* Generates invasion embeds
Expand All @@ -15,7 +18,7 @@ class InvasionEmbed extends BaseEmbed {
super();

this.color = 0x3498db;
this.url = 'http://warframe.wikia.com/wiki/Invasion';
this.url = `${wikiBase}Invasion`;
if (invasions.length > 1) {
this.fields = invasions.map((i) => {
let rewards = i.defenderReward.asString;
Expand Down Expand Up @@ -46,7 +49,7 @@ class InvasionEmbed extends BaseEmbed {
}

this.thumbnail = {
url: 'http://i.imgur.com/QUPS0ql.png',
url: invasionThumb,
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/embeds/PriceCheckEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PriceCheckEmbed extends BaseEmbed {
},
];
this.footer = {
icon_url: 'https://cdn.discordapp.com/icons/195582152849620992/4c1fbd47b3e6c8d49b6d2362c79a537b.jpg',
icon_url: 'https://staging.nexushub.co/img/brand/nexushub-logo-color.png',
text: 'Pricechecks provided by Nexus Stats - https://nexus-stats.com',
};
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/SalesEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const darvo = `${assetBase}/img/darvo-md.png`;

/**
* Generates daily deal embeds
Expand All @@ -17,7 +20,7 @@ class SalesEmbed extends BaseEmbed {
this.color = 0x0000ff;
this.title = sales[0].isPopular ? `[${platform.toUpperCase()}] Popular Sales ` : `[${platform.toUpperCase()}] Featured Deal`;
this.thumbnail = {
url: 'http://i.imgur.com/i9IXX7P.png',
url: darvo,
};
this.fields = [];
sales.forEach((sale) => {
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/ShieldEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const corpus = `${assetBase}/img/corpus.png`;

function shieldCalc(baseShields, baseLevel, currentLevel) {
return (parseFloat(baseShields)
Expand All @@ -26,7 +29,7 @@ class ShieldEmbed extends BaseEmbed {
this.title = 'Warframe - Shields';
this.url = 'https://warframe.com';
this.thumbnail = {
url: 'http://i.imgur.com/BVUXIjA.png',
url: corpus,
};
this.fields = [
{
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/SimarisEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const simarisThumb = `${assetBase}/img/simaris.png`;

/**
* Generates simaris embeds
Expand All @@ -15,7 +18,7 @@ class SimarisEmbed extends BaseEmbed {
super();

this.thumbnail = {
url: 'http://i.imgur.com/mRKOHyv.png',
url: simarisThumb,
};
this.title = `[${platform.toUpperCase()}] Worldstate - Sanctuary`;
this.color = simaris.isTargetActive > 2 ? 0x00ff00 : 0xff0000;
Expand Down
5 changes: 4 additions & 1 deletion src/embeds/SortieEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');
const { assetBase } = require('../CommonFunctions');

const sortieThumb = `${assetBase}/img/sortie.png`;

/**
* Generates sortie embeds
Expand All @@ -26,7 +29,7 @@ class SortieEmbed extends BaseEmbed {

this.title = `[${platform.toUpperCase()}] Worldstate - Sortie`;
this.thumbnail = {
url: 'http://i.imgur.com/wWBRhaB.png',
url: sortieThumb,
};
}
}
Expand Down
Loading

0 comments on commit 5ad7ae8

Please sign in to comment.