From 6d33d45bb3904dcf4a937ba444015dab82c08706 Mon Sep 17 00:00:00 2001 From: jgaribsin <16392336+jgaribsin@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:50:35 -0600 Subject: [PATCH] #patch added style tag parsing to announcements, updated major order embed for defend missions - including objective wiki jsons, not active yet --- src/handlers/cron/deliverUpdates.ts | 30 ++++++++++++--- src/handlers/embed.ts | 37 +++++++++++++------ wiki/objectives/activate_e_710_pumps.json | 16 ++++++++ .../activate_terminid_control_system.json | 16 ++++++++ wiki/objectives/blitz_search_and_destroy.json | 16 ++++++++ wiki/objectives/destroy_command_bunkers.json | 16 ++++++++ .../destroy_transmission_network.json | 16 ++++++++ .../objectives/eliminate_automaton_hulks.json | 16 ++++++++ wiki/objectives/eliminate_bile_titans.json | 16 ++++++++ .../eliminate_brood_commanders.json | 16 ++++++++ wiki/objectives/eliminate_chargers.json | 16 ++++++++ wiki/objectives/eliminate_devastators.json | 16 ++++++++ wiki/objectives/emergency_evacuation.json | 16 ++++++++ .../eradicate_automaton_forces.json | 16 ++++++++ wiki/objectives/eradicate_terminid_swarm.json | 16 ++++++++ wiki/objectives/launch_icbm.json | 16 ++++++++ wiki/objectives/pump_fuel_to_icbm.json | 16 ++++++++ wiki/objectives/purge_hatcheries.json | 16 ++++++++ .../retrieve_essential_personnel.json | 16 ++++++++ wiki/objectives/retrieve_valuable_data.json | 16 ++++++++ wiki/objectives/sabotage_air_base.json | 16 ++++++++ wiki/objectives/sabotage_supply_bases.json | 16 ++++++++ wiki/objectives/spread_democracy.json | 16 ++++++++ .../terminate_illegal_broadcast.json | 16 ++++++++ wiki/objectives/upload_escape_pod_data.json | 16 ++++++++ 25 files changed, 418 insertions(+), 17 deletions(-) create mode 100644 wiki/objectives/activate_e_710_pumps.json create mode 100644 wiki/objectives/activate_terminid_control_system.json create mode 100644 wiki/objectives/blitz_search_and_destroy.json create mode 100644 wiki/objectives/destroy_command_bunkers.json create mode 100644 wiki/objectives/destroy_transmission_network.json create mode 100644 wiki/objectives/eliminate_automaton_hulks.json create mode 100644 wiki/objectives/eliminate_bile_titans.json create mode 100644 wiki/objectives/eliminate_brood_commanders.json create mode 100644 wiki/objectives/eliminate_chargers.json create mode 100644 wiki/objectives/eliminate_devastators.json create mode 100644 wiki/objectives/emergency_evacuation.json create mode 100644 wiki/objectives/eradicate_automaton_forces.json create mode 100644 wiki/objectives/eradicate_terminid_swarm.json create mode 100644 wiki/objectives/launch_icbm.json create mode 100644 wiki/objectives/pump_fuel_to_icbm.json create mode 100644 wiki/objectives/purge_hatcheries.json create mode 100644 wiki/objectives/retrieve_essential_personnel.json create mode 100644 wiki/objectives/retrieve_valuable_data.json create mode 100644 wiki/objectives/sabotage_air_base.json create mode 100644 wiki/objectives/sabotage_supply_bases.json create mode 100644 wiki/objectives/spread_democracy.json create mode 100644 wiki/objectives/terminate_illegal_broadcast.json create mode 100644 wiki/objectives/upload_escape_pod_data.json diff --git a/src/handlers/cron/deliverUpdates.ts b/src/handlers/cron/deliverUpdates.ts index e51aaea..6fed140 100644 --- a/src/handlers/cron/deliverUpdates.ts +++ b/src/handlers/cron/deliverUpdates.ts @@ -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(//g, '**').replace(/<\/i>/g, '**') + ); + if (event.message) + eventEmbed.setDescription( + event.message.replace(//g, '**').replace(/<\/i>/g, '**') + ); // send new updates to subscribed channels const promises: Promise[] = []; @@ -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(//g, '**') + .replace(/<\/i>/g, '**') + ) + .setDescription( + message + .split('\n') + .slice(1) + .join('\n') + .replace(//g, '**') + .replace(/<\/i>/g, '**') + ) .setFooter({text: SUBSCRIBE_FOOTER}) .setTimestamp(), ] @@ -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(//g, '**').replace(/<\/i>/g, '**') + ) .setFooter({text: SUBSCRIBE_FOOTER}) .setTimestamp(), ]; diff --git a/src/handlers/embed.ts b/src/handlers/embed.ts index fbc2f74..200a85e 100644 --- a/src/handlers/embed.ts +++ b/src/handlers/embed.ts @@ -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, + }; + }) ); } diff --git a/wiki/objectives/activate_e_710_pumps.json b/wiki/objectives/activate_e_710_pumps.json new file mode 100644 index 0000000..0d383b5 --- /dev/null +++ b/wiki/objectives/activate_e_710_pumps.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/activate_terminid_control_system.json b/wiki/objectives/activate_terminid_control_system.json new file mode 100644 index 0000000..8111d14 --- /dev/null +++ b/wiki/objectives/activate_terminid_control_system.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/blitz_search_and_destroy.json b/wiki/objectives/blitz_search_and_destroy.json new file mode 100644 index 0000000..db8c23c --- /dev/null +++ b/wiki/objectives/blitz_search_and_destroy.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/destroy_command_bunkers.json b/wiki/objectives/destroy_command_bunkers.json new file mode 100644 index 0000000..ff77c1a --- /dev/null +++ b/wiki/objectives/destroy_command_bunkers.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/destroy_transmission_network.json b/wiki/objectives/destroy_transmission_network.json new file mode 100644 index 0000000..fd43faa --- /dev/null +++ b/wiki/objectives/destroy_transmission_network.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/eliminate_automaton_hulks.json b/wiki/objectives/eliminate_automaton_hulks.json new file mode 100644 index 0000000..1d16e54 --- /dev/null +++ b/wiki/objectives/eliminate_automaton_hulks.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/eliminate_bile_titans.json b/wiki/objectives/eliminate_bile_titans.json new file mode 100644 index 0000000..1981af4 --- /dev/null +++ b/wiki/objectives/eliminate_bile_titans.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/eliminate_brood_commanders.json b/wiki/objectives/eliminate_brood_commanders.json new file mode 100644 index 0000000..fd43d5b --- /dev/null +++ b/wiki/objectives/eliminate_brood_commanders.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/eliminate_chargers.json b/wiki/objectives/eliminate_chargers.json new file mode 100644 index 0000000..4da4b35 --- /dev/null +++ b/wiki/objectives/eliminate_chargers.json @@ -0,0 +1,16 @@ +{ + "page": "eliminate_chargers", + "title": "Eliminate Chargers", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/eliminate_devastators.json b/wiki/objectives/eliminate_devastators.json new file mode 100644 index 0000000..e1dd739 --- /dev/null +++ b/wiki/objectives/eliminate_devastators.json @@ -0,0 +1,16 @@ +{ + "page": "eliminate_devastators", + "title": "Eliminate Devastators", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/emergency_evacuation.json b/wiki/objectives/emergency_evacuation.json new file mode 100644 index 0000000..4901ec3 --- /dev/null +++ b/wiki/objectives/emergency_evacuation.json @@ -0,0 +1,16 @@ +{ + "page": "emergency_evacuation", + "title": "Emergency Evacuation", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/eradicate_automaton_forces.json b/wiki/objectives/eradicate_automaton_forces.json new file mode 100644 index 0000000..9c46b19 --- /dev/null +++ b/wiki/objectives/eradicate_automaton_forces.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/eradicate_terminid_swarm.json b/wiki/objectives/eradicate_terminid_swarm.json new file mode 100644 index 0000000..24a6241 --- /dev/null +++ b/wiki/objectives/eradicate_terminid_swarm.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/launch_icbm.json b/wiki/objectives/launch_icbm.json new file mode 100644 index 0000000..48089c8 --- /dev/null +++ b/wiki/objectives/launch_icbm.json @@ -0,0 +1,16 @@ +{ + "page": "launch_icbm", + "title": "Launch ICBM", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "Difficulty: 3+", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/pump_fuel_to_icbm.json b/wiki/objectives/pump_fuel_to_icbm.json new file mode 100644 index 0000000..5bf3386 --- /dev/null +++ b/wiki/objectives/pump_fuel_to_icbm.json @@ -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": "" +} \ No newline at end of file diff --git a/wiki/objectives/purge_hatcheries.json b/wiki/objectives/purge_hatcheries.json new file mode 100644 index 0000000..3e37072 --- /dev/null +++ b/wiki/objectives/purge_hatcheries.json @@ -0,0 +1,16 @@ +{ + "page": "purge_hatcheries", + "title": "Purge Hatcheries", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/retrieve_essential_personnel.json b/wiki/objectives/retrieve_essential_personnel.json new file mode 100644 index 0000000..0ab83a0 --- /dev/null +++ b/wiki/objectives/retrieve_essential_personnel.json @@ -0,0 +1,16 @@ +{ + "page": "retrieve_essential_personnel", + "title": "Retrieve Essential Personnel", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/retrieve_valuable_data.json b/wiki/objectives/retrieve_valuable_data.json new file mode 100644 index 0000000..8e0109a --- /dev/null +++ b/wiki/objectives/retrieve_valuable_data.json @@ -0,0 +1,16 @@ +{ + "page": "retrieve_valuable_data", + "title": "Retrieve Valuable Data", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/sabotage_air_base.json b/wiki/objectives/sabotage_air_base.json new file mode 100644 index 0000000..9011af2 --- /dev/null +++ b/wiki/objectives/sabotage_air_base.json @@ -0,0 +1,16 @@ +{ + "page": "sabotage_air_base", + "title": "Sabotage Air Base", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/sabotage_supply_bases.json b/wiki/objectives/sabotage_supply_bases.json new file mode 100644 index 0000000..8b18599 --- /dev/null +++ b/wiki/objectives/sabotage_supply_bases.json @@ -0,0 +1,16 @@ +{ + "page": "sabotage_supply_bases", + "title": "Sabotage Supply Bases", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "All planets", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/spread_democracy.json b/wiki/objectives/spread_democracy.json new file mode 100644 index 0000000..e4cb73f --- /dev/null +++ b/wiki/objectives/spread_democracy.json @@ -0,0 +1,16 @@ +{ + "page": "spread_democracy", + "title": "Spread Democracy", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "Difficulty: 1-2", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/terminate_illegal_broadcast.json b/wiki/objectives/terminate_illegal_broadcast.json new file mode 100644 index 0000000..f07211c --- /dev/null +++ b/wiki/objectives/terminate_illegal_broadcast.json @@ -0,0 +1,16 @@ +{ + "page": "terminate_illegal_broadcast", + "title": "Terminate Illegal Broadcast", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "Difficulty: 1-2", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file diff --git a/wiki/objectives/upload_escape_pod_data.json b/wiki/objectives/upload_escape_pod_data.json new file mode 100644 index 0000000..9d5453b --- /dev/null +++ b/wiki/objectives/upload_escape_pod_data.json @@ -0,0 +1,16 @@ +{ + "page": "upload_escape_pod_data", + "title": "Upload Escape Pod Data", + "description": "", + "content": "", + "fields": [ + { + "name": "Primary Objective", + "value": "Difficulty: 1-2", + "inline": true + } + ], + "emoji": "", + "thumbnail": "", + "image": "" +} \ No newline at end of file