Skip to content

Commit

Permalink
#patch added style tag parsing to announcements, updated major order …
Browse files Browse the repository at this point in the history
…embed for defend missions

- including objective wiki jsons, not active yet
  • Loading branch information
jgaribsin committed Apr 1, 2024
1 parent 51b7988 commit 6d33d45
Show file tree
Hide file tree
Showing 25 changed files with 418 additions and 17 deletions.
30 changes: 25 additions & 5 deletions src/handlers/cron/deliverUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,14 @@ export async function newEventUpdate(event: GlobalEvent, channelIds: string[]) {
iconURL: altSprites['Humans'],
})
.setFooter({text: SUBSCRIBE_FOOTER});
if (event.title) eventEmbed.setTitle(event.title);
if (event.message) eventEmbed.setDescription(event.message);
if (event.title)
eventEmbed.setTitle(
event.title.replace(/<i=\d>/g, '**').replace(/<\/i>/g, '**')
);
if (event.message)
eventEmbed.setDescription(
event.message.replace(/<i=\d>/g, '**').replace(/<\/i>/g, '**')
);

// send new updates to subscribed channels
const promises: Promise<any>[] = [];
Expand Down Expand Up @@ -348,8 +354,20 @@ export async function newNewsUpdate(news: NewsFeedItem, channelIds: string[]) {
name: 'New Dispatch from SE Command!',
iconURL: altSprites['Humans'],
})
.setTitle(message.split('\n')[0])
.setDescription(message.split('\n').slice(1).join('\n'))
.setTitle(
message
.split('\n')[0]
.replace(/<i=\d>/g, '**')
.replace(/<\/i>/g, '**')
)
.setDescription(
message
.split('\n')
.slice(1)
.join('\n')
.replace(/<i=\d>/g, '**')
.replace(/<\/i>/g, '**')
)
.setFooter({text: SUBSCRIBE_FOOTER})
.setTimestamp(),
]
Expand All @@ -359,7 +377,9 @@ export async function newNewsUpdate(news: NewsFeedItem, channelIds: string[]) {
name: 'New Dispatch from SE Command!',
iconURL: altSprites['Humans'],
})
.setDescription(news.message)
.setDescription(
news.message.replace(/<i=\d>/g, '**').replace(/<\/i>/g, '**')
)
.setFooter({text: SUBSCRIBE_FOOTER})
.setTimestamp(),
];
Expand Down
37 changes: 25 additions & 12 deletions src/handlers/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,33 @@ export function majorOrderEmbed(assignment: Assignment) {
);

if (settingsType === 4) {
const tasksDisplay = tasks.map((t, i) => ({
completed: progress[i] === 1,
planetName: getPlanetName(t.values[2]),
progress:
campaigns.find(c => c.planetName === getPlanetName(t.values[2]))
?.planetData.liberation ?? 0,
}));
const tasksDisplay = tasks.map((t, i) => {
const campaign = campaigns.find(
c => c.planetName === getPlanetName(t.values[2])
);
return {
completed: progress[i] === 1,
planetName: getPlanetName(t.values[2]),
type: campaign?.campaignType,
progress:
campaign?.campaignType === 'Defend'
? campaign?.planetEvent?.defence ?? 0
: campaign?.planetData.liberation ?? 0,
};
});

embedFields.push(
...tasksDisplay.map(task => ({
name: task.planetName,
value: task.completed ? '**COMPLETE**' : `${task.progress.toFixed(2)}%`,
inline: true,
}))
...tasksDisplay.map(task => {
const {completed, planetName, progress, type} = task;
let text = '';
if (type) text += `**${type}**: ${progress.toFixed(2)}%`;
else text += '**COMPLETE**';
return {
name: planetName,
value: text,
inline: true,
};
})
);
}

Expand Down
16 changes: 16 additions & 0 deletions wiki/objectives/activate_e_710_pumps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "activate_e_710_pumps",
"title": "Activate E-710 Pumps",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/activate_terminid_control_system.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "activate_terminid_control_system",
"title": "Activate Terminid Control System",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/blitz_search_and_destroy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "blitz_search_and_destroy",
"title": "Blitz: Search and Destroy",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/destroy_command_bunkers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "destroy_command_bunkers",
"title": "Destroy Command Bunkers",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "Difficulty: 7+",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/destroy_transmission_network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "destroy_transmission_network",
"title": "Destroy Transmission Network",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/eliminate_automaton_hulks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "eliminate_automaton_hulks",
"title": "Eliminate Automaton Hulks",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/eliminate_bile_titans.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "eliminate_bile_titans",
"title": "Eliminate Bile Titans",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/eliminate_brood_commanders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "eliminate_brood_commanders",
"title": "Eliminate Brood Commanders",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/eliminate_chargers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "eliminate_chargers",
"title": "Eliminate Chargers",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/eliminate_devastators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "eliminate_devastators",
"title": "Eliminate Devastators",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/emergency_evacuation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "emergency_evacuation",
"title": "Emergency Evacuation",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/eradicate_automaton_forces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "eradicate_automaton_forces",
"title": "Eradicate Automaton Forces",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/eradicate_terminid_swarm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "eradicate_terminid_swarm",
"title": "Eradicate Terminid Swarm",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/launch_icbm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "launch_icbm",
"title": "Launch ICBM",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "Difficulty: 3+",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/pump_fuel_to_icbm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "pump_fuel_to_icbm",
"title": "Pump Fuel To ICBM",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "Difficulty: 1-2",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
16 changes: 16 additions & 0 deletions wiki/objectives/purge_hatcheries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"page": "purge_hatcheries",
"title": "Purge Hatcheries",
"description": "",
"content": "",
"fields": [
{
"name": "Primary Objective",
"value": "All planets",
"inline": true
}
],
"emoji": "",
"thumbnail": "",
"image": ""
}
Loading

0 comments on commit 6d33d45

Please sign in to comment.