Skip to content

Commit

Permalink
fix: style & linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Oct 25, 2018
1 parent a993f54 commit f679523
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/embeds/SyndicateEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,11 @@ const BaseEmbed = require('./BaseEmbed.js');

const values = ['all', 'Arbiters of Hexis', 'Perrin Sequence', 'Cephalon Suda', 'Steel Meridian', 'New Loka', 'Red Veil', 'Ostrons', 'Assassins', 'Quills'];

const makeMissionValue = (mission, syndMissions) => {
if (!mission) {
return 'No Nodes or Jobs Available';
}
const jobs = mission.jobs.length ? makeJobs(mission, syndMissions.length) : '';
const nodes = mission.nodes.length ? `${mission.nodes.join('\n')}${syndMissions.length < 2 ? '' : `\n\n**Expires in ${mission.eta}**`}` : '';
let value = 'No Nodes or Jobs Available';
if (jobs.length) {
value = jobs;
} else if (nodes.length) {
value = nodes;
}
return value;
}

const makeJobs = (mission, numSyndMissions) => {
if (mission.jobs && mission.jobs.length) {
const tokens = [];
mission.jobs.forEach(job => {
const totalStanding = job.standingStages.reduce((a, b) => a + b, 0)
mission.jobs.forEach((job) => {
const totalStanding = job.standingStages.reduce((a, b) => a + b, 0);
const levels = job.enemyLevels.join(' - ');
const rewards = job.rewardPool.join(', ');
tokens.push(`:arrow_up: ${totalStanding} - ${job.type} (${levels})`);
Expand All @@ -39,6 +24,21 @@ const makeJobs = (mission, numSyndMissions) => {
return undefined;
};

const makeMissionValue = (mission, syndMissions) => {
if (!mission) {
return 'No Nodes or Jobs Available';
}
const jobs = mission.jobs.length ? makeJobs(mission, syndMissions.length) : '';
const nodes = mission.nodes.length ? `${mission.nodes.join('\n')}${syndMissions.length < 2 ? '' : `\n\n**Expires in ${mission.eta}**`}` : '';
let value = 'No Nodes or Jobs Available';
if (jobs.length) {
value = jobs;
} else if (nodes.length) {
value = nodes;
}
return value;
};

/**
* Generates syndicate embeds
*/
Expand Down Expand Up @@ -84,13 +84,11 @@ class SyndicateEmbed extends BaseEmbed {
this.description = makeMissionValue(syndMissions[0], syndMissions);
this.fields = undefined;
} else {
this.fields = syndMissions.map((m) => {
return {
name: syndMissions.length < 2 ? '\u200B' : m.syndicate,
value: makeMissionValue(m, syndMissions),
inline: !(m.jobs.length > 0),
};
});
this.fields = syndMissions.map(m => ({
name: syndMissions.length < 2 ? '\u200B' : m.syndicate,
value: makeMissionValue(m, syndMissions),
inline: !(m.jobs.length > 0),
}));
}
}
}
Expand Down

0 comments on commit f679523

Please sign in to comment.