Skip to content

Commit 4b7e90e

Browse files
chore: use built in set methods for embeds
1 parent 76d25cf commit 4b7e90e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+692
-674
lines changed

src/embeds/AcolyteEmbed.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@ export default class AcolyteEmbed extends BaseEmbed {
1515
constructor(enemies, { platform, i18n, locale }) {
1616
super(locale);
1717

18-
this.thumbnail = {
19-
url: acolyteThumb,
20-
};
21-
this.title = i18n`[${platform.toUpperCase()}] Acolytes`;
18+
this.setThumbnail(acolyteThumb);
19+
this.setTitle(i18n`[${platform.toUpperCase()}] Acolytes`);
2220
if (Array.isArray(enemies) && enemies.length > 1) {
23-
this.color = enemies.length > 2 ? 0x00ff00 : 0xff0000;
24-
this.fields = enemies.map((e) => ({
25-
name: e.agentType,
26-
value: i18n`Last discovered at ${e.lastDiscoveredAt}.
21+
this.setColor(enemies.length > 2 ? 0x00ff00 : 0xff0000);
22+
this.setFields(
23+
enemies.map((e) => ({
24+
name: e.agentType,
25+
value: i18n`Last discovered at ${e.lastDiscoveredAt}.
2726
It has ${(100 * Number(e.healthPercent)).toFixed(2)}% health remaining
2827
and is currently ${e.isDiscovered ? 'discovered' : 'not discovered'}`,
29-
}));
28+
}))
29+
);
3030
} else if (!Array.isArray(enemies) || enemies.length === 1) {
3131
const e = Array.isArray(enemies) ? enemies[0] : enemies;
32-
this.title = i18n`[${platform.toUpperCase()}] ${e.agentType}`;
33-
this.description = i18n`Enemy ${e.isDiscovered ? i18n`Discovered` : i18n`Hiding`}!`;
34-
this.color = 0xaf5b4b;
35-
this.fields = [
32+
this.setTitle(i18n`[${platform.toUpperCase()}] ${e.agentType}`);
33+
this.setDescription(i18n`Enemy ${e.isDiscovered ? i18n`Discovered` : i18n`Hiding`}!`);
34+
this.setColor(0xaf5b4b);
35+
this.setFields([
3636
{ name: '\u200B', value: `**${e.isDiscovered ? '' : 'Last '}Discovered At:** ${e.lastDiscoveredAt}` },
3737
{ name: '\u200B', value: `**Health Remaining:** ${(100 * Number(e.healthPercent)).toFixed(2)}%` },
3838
{ name: '\u200B', value: `Will flee after ${e.fleeDamage} damage.\nGet after the Acolyte, Tenno!` },
39-
];
39+
]);
4040
} else {
41-
this.color = 0xaf5b4b;
42-
this.fields = [
41+
this.setColor(0xaf5b4b);
42+
this.setFields([
4343
{
4444
name: i18n`There are currently no enemies to combat`,
4545
value: '\u200B',
4646
},
47-
];
47+
]);
4848
}
4949
}
5050
}

src/embeds/AlertEmbed.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,50 @@ export default class AlertEmbed extends BaseEmbed {
1515
constructor(alerts, { platform, i18n, locale }) {
1616
super(locale);
1717

18-
this.thumbnail = {
19-
url: alertThumb,
20-
};
21-
this.color = 0xf1c40f;
18+
this.setThumbnail(alertThumb);
19+
this.setColor(0xf1c40f);
2220
// compact
2321
if (Array.isArray(alerts) && alerts.length > 1) {
24-
this.fields = alerts.map((a) => ({
25-
name: i18n`${a.mission.reward.asString} | ${a.eta} left`,
26-
value: i18n`${a.mission.faction} ${a.mission.type} on ${a.mission.node}\nlevel ${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}\n\u200B`,
27-
}));
28-
this.title = i18n`[${platform.toUpperCase()}] Worldstate - Alerts`;
22+
this.setFields(
23+
alerts.map((a) => ({
24+
name: i18n`${a.mission.reward.asString} | ${a.eta} left`,
25+
value: i18n`${a.mission.faction} ${a.mission.type} on ${a.mission.node}\nlevel ${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}\n\u200B`,
26+
}))
27+
);
28+
this.setTitle(i18n`[${platform.toUpperCase()}] Worldstate - Alerts`);
2929
} else {
3030
// divided
3131
const a = Array.isArray(alerts) ? alerts[0] : alerts;
32-
this.title = i18n`[${platform.toUpperCase()}] ${
33-
a.mission.reward.itemString || i18n`${a.mission.reward.credits} Credits`
34-
}`;
35-
this.color = a.mission.reward.color;
36-
this.thumbnail.url = a.mission.reward.thumbnail;
32+
this.setTitle(
33+
i18n`[${platform.toUpperCase()}] ${a.mission.reward.itemString || i18n`${a.mission.reward.credits} Credits`}`
34+
);
35+
this.setColor(a.mission.reward.color);
36+
this.setThumbnail(a.mission.reward.thumbnail);
3737
const summary = i18n`${a.mission.faction} ${a.mission.type} on ${a.mission.node}`;
38-
this.description = a.description;
38+
this.setDescription(a.description);
3939

40-
this.fields = [];
40+
this.setFields([]);
4141
if (this.description !== summary) {
42-
this.fields.push({ name: i18n`Mission`, value: i18n`${a.mission.faction} ${a.mission.type}`, inline: true });
43-
this.fields.push({ name: i18n`Location`, value: a.mission.node, inline: true });
42+
this.addFields([{ name: i18n`Mission`, value: i18n`${a.mission.faction} ${a.mission.type}`, inline: true }]);
43+
this.addFields([{ name: i18n`Location`, value: a.mission.node, inline: true }]);
4444
}
45-
this.fields.push({
45+
this.addFields({
4646
name: 'Levels:',
4747
value: `${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}`,
4848
inline: true,
4949
});
5050

51-
this.fields.push({
51+
this.addFields({
5252
name: i18n`Archwing Required`,
5353
value: a.mission.archwingRequired ? i18n`Yes` : i18n`No`,
5454
inline: true,
5555
});
5656

57-
if (this.title.indexOf('Cr') === -1) {
58-
this.fields.push({ name: '\u200B', value: i18n`**Credits:** ${a.mission.reward.credits}`, inline: true });
57+
if (this.data.title.indexOf('Cr') === -1) {
58+
this.addFields({ name: '\u200B', value: i18n`**Credits:** ${a.mission.reward.credits}`, inline: true });
5959
}
60-
this.footer.text = i18n`${a.eta} remaining • Expires `;
61-
this.timestamp = a.expiry;
60+
this.setFooter({ text: i18n`${a.eta} remaining • Expires ` });
61+
this.setTimestamp(a.expiry);
6262
}
6363
}
6464
}

src/embeds/ArbitrationEmbed.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ export default class ArbitrationEmbed extends BaseEmbed {
1414
*/
1515
constructor(arbitration, { platform, i18n, locale }) {
1616
super(locale);
17-
this.thumbnail.url = arbiThumb;
18-
this.color = 0x742725;
19-
this.title = i18n`[${platform.toUpperCase()}] Worldstate - Arbitration`;
20-
this.fields.push({
21-
name: arbitration.node || '???',
22-
value: arbitration.type || '???',
23-
});
24-
this.footer.text = i18n`Expires`;
25-
this.timestamp = arbitration.expiry;
17+
this.setThumbnail(arbiThumb);
18+
this.setColor(0x742725);
19+
this.setTitle(i18n`[${platform.toUpperCase()}] Worldstate - Arbitration`);
20+
this.addFields([
21+
{
22+
name: arbitration.node || '???',
23+
value: arbitration.type || '???',
24+
},
25+
]);
26+
this.setFooter({ text: i18n`Expires` });
27+
this.setTimestamp(arbitration.expiry);
2628
}
2729
}

src/embeds/BuildEmbed.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@ export default class BuildEmbed extends BaseEmbed {
1010
constructor(build) {
1111
super();
1212
const sections = build.body.split(';');
13-
this.color = 0xf1c40f;
14-
this.title = build.title;
15-
this.fields = [];
13+
this.setColor(0xf1c40f);
14+
this.setTitle(build.title);
15+
this.setFields([]);
1616
sections.forEach((value, index) => {
1717
if (index === 0) {
18-
this.description = value;
18+
this.setDescription(value);
1919
} else {
2020
this.addFields({
2121
name: '\u200B',
2222
value,
2323
});
2424
}
2525
});
26-
this.image = { url: build.url || build.image };
27-
this.footer.text = `${build.id}${build.isPublic ? ' • Public' : ''} • Owned by ${
28-
typeof build.owner === 'object' ? build.owner.tag : build.owner
29-
}`;
26+
this.setImage({ url: build.url || build.image });
27+
this.setFooter({
28+
text: `${build.id}${build.isPublic ? ' • Public' : ''} • Owned by ${
29+
typeof build.owner === 'object' ? build.owner.tag : build.owner
30+
}`,
31+
});
3032
}
3133
}

src/embeds/CambionEmbed.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,16 @@ export default class CambionEmbed extends BaseEmbed {
3535
*/
3636
constructor(state, { i18n, locale }) {
3737
super(locale);
38-
this.title = i18n`Cambion Drift Cycle - ${toTitleCase(state.active)}`;
39-
this.color = state.active === 'fass' ? 0xc6733f : 0x415b9e;
40-
this.thumbnail = {
41-
url: state.active === 'fass' ? fass : vome,
42-
};
38+
this.setTitle(i18n`Cambion Drift Cycle - ${toTitleCase(state.active)}`);
39+
this.setColor(state.active === 'fass' ? 0xc6733f : 0x415b9e);
40+
this.setThumbnail(state.active === 'fass' ? fass : vome);
4341

4442
const next = toTitleCase(state.active === 'fass' ? 'vome' : 'fass');
4543

4644
const nextCtd = i18n`Time remaining until ${next}: ${rTime(state.expiry)}`;
47-
this.description = `${state.bounty ? makeJobs(state.bounty, i18n) : ''}\n\n${nextCtd}`;
45+
this.setDescription(`${state.bounty ? makeJobs(state.bounty, i18n) : ''}\n\n${nextCtd}`);
4846

49-
this.footer.text = i18n`${next} starts `;
50-
this.timestamp = new Date(state.expiry).getTime();
47+
this.setFooter({ text: i18n`${next} starts ` });
48+
this.setTimestamp(new Date(state.expiry).getTime());
5149
}
5250
}

src/embeds/CompanionEmbed.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class CompanionEmbed extends BaseEmbed {
1414
.setURL(`https://warframe.fandom.com/wiki/${companion.name.replace(/\s/g, '_')}`)
1515
.setThumbnail(`https://cdn.warframestat.us/img/${companion.imageName}`)
1616
.setDescription(companion.description)
17-
.addFields(
17+
.addFields([
1818
{ name: i18n`Health`, value: `${companion.health}`, inline: true },
1919
{ name: i18n`Power`, value: `${companion.power}`, inline: true },
2020
{ name: i18n`Armor`, value: `${companion.armor}`, inline: true },
@@ -25,7 +25,7 @@ export default class CompanionEmbed extends BaseEmbed {
2525
inline: true,
2626
},
2727
{ name: `Build Price`, value: `${companion.buildPrice}${emojify('credits')}`, inline: true },
28-
{ name: `Build Skip`, value: `${companion.skipBuildTimePrice}${emojify('p')}`, inline: true }
29-
);
28+
{ name: `Build Skip`, value: `${companion.skipBuildTimePrice}${emojify('p')}`, inline: true },
29+
]);
3030
}
3131
}

src/embeds/ComponentEmbed.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ import BaseEmbed from './BaseEmbed.js';
33
export default class ComponentEmbed extends BaseEmbed {
44
constructor(components, { i18n, locale }) {
55
super(locale);
6-
this.title = 'Components';
7-
this.color = 0xd3d3d3;
8-
this.fields = components.map((component) => {
9-
const tokens = [];
10-
tokens.push(`_${component.description}_\n`);
11-
tokens.push(component.itemCount ? i18n`**#:** ${component.itemCount}\n` : '');
12-
tokens.push(component.ducats ? i18n`**Ducats:** ${component.ducats}\n` : '');
13-
tokens.push(i18n`**Tradable:** ${component.ducats ? i18n`Yes` : i18n`No`}`);
14-
tokens.push('\n\u200B\n');
15-
return {
16-
name: component.name,
17-
value: tokens.join(''),
18-
};
19-
});
6+
this.setTitle('Components');
7+
this.setColor(0xd3d3d3);
8+
this.setFields(
9+
components.map((component) => {
10+
const tokens = [];
11+
tokens.push(`_${component.description}_\n`);
12+
tokens.push(component.itemCount ? i18n`**#:** ${component.itemCount}\n` : '');
13+
tokens.push(component.ducats ? i18n`**Ducats:** ${component.ducats}\n` : '');
14+
tokens.push(i18n`**Tradable:** ${component.ducats ? i18n`Yes` : i18n`No`}`);
15+
tokens.push('\n\u200B\n');
16+
return {
17+
name: component.name,
18+
value: tokens.join(''),
19+
};
20+
})
21+
);
2022
}
2123
}

src/embeds/ConclaveChallengeEmbed.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ export default class ConclaveChallengeEmbed extends BaseEmbed {
1313
super(locale);
1414

1515
const categoryInValues = category && values.indexOf(category.toLowerCase()) !== -1;
16-
this.color = categoryInValues ? 0x00ff00 : 0xff0000;
16+
this.setColor(categoryInValues ? 0x00ff00 : 0xff0000);
1717
if (categoryInValues) {
18-
this.fields = challenges
19-
.filter((c) => compareCCategory(c, category))
20-
.map((c) => ({
21-
name: c.mode,
22-
value: `${c.description} expires in ${c.endString}`,
23-
}));
18+
this.setFields(
19+
challenges
20+
.filter((c) => compareCCategory(c, category))
21+
.map((c) => ({
22+
name: c.mode,
23+
value: `${c.description} expires in ${c.endString}`,
24+
}))
25+
);
2426
} else {
25-
this.fields = [
27+
this.setFields([
2628
{
2729
name: i18n`No such conclave category`,
2830
value: `Valid values: ${values.join(', ')}`,
2931
},
30-
];
32+
]);
3133
}
32-
this.title = `${platform ? `[${platform.toUpperCase()}] ` : ''}Current Challenges for category: ${
33-
category || 'none'
34-
}`;
35-
this.thumbnail = {
36-
url: conclaveThumb,
37-
};
34+
this.setTitle(
35+
`${platform ? `[${platform.toUpperCase()}] ` : ''}Current Challenges for category: ${category || 'none'}`
36+
);
37+
this.setThumbnail(conclaveThumb);
3838
}
3939
}

src/embeds/ConstructionEmbed.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ export default class ConstructionEmbed extends BaseEmbed {
44
constructor(constructionProgress, { platform, i18n, locale }) {
55
super(locale);
66

7-
this.color = 0xff6961;
8-
this.fields = [
7+
this.setColor(0xff6961);
8+
this.setFields([
99
{
1010
name: i18n`[${platform.toUpperCase()}] Construction Status:`,
1111
value: i18n`\`Razorback: ${constructionProgress.razorbackProgress}\`
1212
\`Fomorian: ${constructionProgress.fomorianProgress}\`
1313
\`Unknown: ${constructionProgress.unknownProgress}\``,
1414
},
15-
];
15+
]);
1616
}
1717
}

src/embeds/DarvoEmbed.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ export default class DarvoEmbed extends BaseEmbed {
88
constructor(deal, { platform, i18n, locale }) {
99
super(locale);
1010
if (Array.isArray(deal)) [deal] = deal;
11-
this.color = 0x0000ff;
12-
this.title = i18n`[${platform.toUpperCase()}] Darvo Deal`;
13-
this.thumbnail = {
14-
url: darvo,
15-
};
16-
this.fields = [
11+
this.setColor(0x0000ff);
12+
this.setTitle(i18n`[${platform.toUpperCase()}] Darvo Deal`);
13+
this.setThumbnail(darvo);
14+
this.setFields([
1715
{
1816
name: i18n`${deal.item}, ${deal.salePrice}p`,
1917
value: `Original price: ${deal.originalPrice}p, expires in ${deal.eta}`,
2018
},
21-
];
22-
this.footer.text = i18n`${deal.total - deal.sold}/${deal.total} left`;
19+
]);
20+
this.setFooter({ text: i18n`${deal.total - deal.sold}/${deal.total} left` });
2321
}
2422
}

src/embeds/DropsEmbed.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class DropsEmbed extends BaseEmbed {
66
constructor(drops, { i18n, locale }) {
77
super(locale);
88
if (!drops || !drops.length) {
9-
this.description = i18n`No drops`;
9+
this.setDescription(i18n`No drops`);
1010
return;
1111
}
1212
const longest = (
@@ -23,10 +23,12 @@ export default class DropsEmbed extends BaseEmbed {
2323
.filter((drop) => drop);
2424

2525
const dropGroups = createGroupedArray(consolidated, 10);
26-
this.fields = dropGroups.map((group) => ({
27-
name: '\u200B',
28-
value: group.join('\n'),
29-
inline: false,
30-
}));
26+
this.setFields(
27+
dropGroups.map((group) => ({
28+
name: '\u200B',
29+
value: group.join('\n'),
30+
inline: false,
31+
}))
32+
);
3133
}
3234
}

0 commit comments

Comments
 (0)