Skip to content

Commit

Permalink
feat: syndicate embed alterations for bounties
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Oct 23, 2018
1 parent d589414 commit a993f54
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 18 deletions.
2 changes: 1 addition & 1 deletion commands.json

Large diffs are not rendered by default.

64 changes: 47 additions & 17 deletions src/embeds/SyndicateEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@ 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)
const levels = job.enemyLevels.join(' - ');
const rewards = job.rewardPool.join(', ');
tokens.push(`:arrow_up: ${totalStanding} - ${job.type} (${levels})`);
tokens.push(`:moneybag: ${rewards}\n`);
});

if (numSyndMissions < 2) {
tokens.push(`\n**Expires in ${mission.eta}**`);
}

return tokens.join('\n');
}
return undefined;
};

/**
* Generates syndicate embeds
*/
Expand Down Expand Up @@ -45,23 +80,18 @@ class SyndicateEmbed extends BaseEmbed {
this.title = `[${platform.toUpperCase()}] ${syndMissions[0].syndicate}`;
this.footer.text = `Expires in ${syndMissions[0].eta}`;
}

this.fields = syndMissions.map((m) => {
const jobs = m.jobs.length ? `${m.jobs.map(job => `:arrow_up:️ ${job.standingStages.reduce((a, b) => a + b, 0)} `
+ `- ${job.type} (${job.enemyLevels.join(' - ')})`).join('\n')}${syndMissions.length < 2 ? '' : `\n\n**Expires in ${m.eta}**`}` : '';
const nodes = m.nodes.length ? `${m.nodes.join('\n')}${syndMissions.length < 2 ? '' : `\n\n**Expires in ${m.eta}**`}` : '';
let value = 'No Nodes or Jobs Available';
if (jobs.length) {
value = jobs;
} else if (nodes.length) {
value = nodes;
}
return {
name: syndMissions.length < 2 ? '\u200B' : m.syndicate,
value,
inline: !(m.jobs.length > 0),
};
});
if (syndMissions.length < 2) {
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.bot = undefined;
Expand Down

0 comments on commit a993f54

Please sign in to comment.