Skip to content

Commit

Permalink
fix: syndicate embed not flexing on missions length
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Mar 29, 2021
1 parent 85e2d19 commit 3796d07
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 80 deletions.
14 changes: 12 additions & 2 deletions src/CommonFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const {

const rssFeeds = require('./resources/rssFeeds');

const logger = require('./Logger');

/**
* API base path
* @type {string]}
Expand Down Expand Up @@ -436,6 +438,8 @@ const checkAndMergeEmbeds = (original, value) => {
}
};

const nav = ['◀', '▶', '⏮', '⏭', '🛑'];

/**
* Create a page collector for the given message and pages
* @param {Discord.Message} msg Message to start the page collector from
Expand All @@ -451,7 +455,9 @@ const createPageCollector = async (msg, pages, author) => {
// await msg.react('🛑');
await msg.react('▶');
// await msg.react('⏭');
const collector = msg.createReactionCollector((reaction, user) => ((['◀', '▶', '⏮', '⏭', '🛑'].includes(reaction.emoji.name)) && user.id === author.id), { time: 600000 });

const rColl = (reaction, user) => (nav.includes(reaction.emoji.name) && user.id === author.id);
const collector = msg.createReactionCollector(rColl, { time: 600000 });
const timeout = setTimeout(() => { msg.reactions.removeAll(); }, 601000);

collector.on('collect', async (reaction) => {
Expand Down Expand Up @@ -499,7 +505,11 @@ const createPageCollector = async (msg, pages, author) => {
} else {
newPage.footer = { text: pageInd };
}
msg.edit({ embed: newPage });
try {
msg.edit({ embed: newPage });
} catch (err) {
logger.error(`${err.message} while editing to ${newPage.title}`);
}
} else if (page < 1) {
page = 1;
} else if (page > pages.length) {
Expand Down
8 changes: 6 additions & 2 deletions src/commands/Worldstate/Syndicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ class Syndicates extends Command {
const platform = platformParam || ctx.platform;
const pages = [];
const matching = (await this.ws.get('syndicateMissions', platform, ctx.language))
.filter(m => m.syndicate.toLowerCase() === syndicate || syndicate === 'all'); if (matching.length) {
.filter(m => m.syndicate.toLowerCase() === syndicate || syndicate === 'all');

if (matching.length) {
matching.forEach((mission) => {
pages.push(new SyndicateEmbed(this.bot, [mission], mission.syndicate, platform, true));
if (mission.nodes.length || mission.jobs.length) {
pages.push(new SyndicateEmbed(this.bot, [mission], mission.syndicate, platform, true));
}
});
await setupPages(pages, { message, settings: this.settings, mm: this.messageManager });
return this.messageManager.statuses.SUCCESS;
Expand Down
14 changes: 12 additions & 2 deletions src/embeds/SyndicateEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,18 @@ class SyndicateEmbed extends BaseEmbed {
this.timestamp = syndMissions[0].expiry;
}
if (syndMissions.length < 2) {
this.description = makeMissionValue(syndMissions[0], syndMissions);
this.fields = undefined;
const missionValue = makeMissionValue(syndMissions[0], syndMissions);

if (missionValue.length < 2000) {
this.description = missionValue;
this.fields = undefined;
} else {
this.fields = missionValue.split('\n\n').map(spv => ({
name: '\u200B',
value: spv,
inline: false,
}));
}
} else {
this.fields = syndMissions.map(m => ({
name: syndMissions.length < 2 ? '\u200B' : m.syndicate,
Expand Down
10 changes: 5 additions & 5 deletions src/resources/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} auf {2} \n Level {3} - {4}",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Sortie",
"[{0}] Worldstate - Nightwave": "[{0}] Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Sortie",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Credits",
"{0} {1} on {2}": "{0} {1} auf {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | {1} left",
"{0} {1} on {2} \n level {3} - {4}\n\u200B": "{0} {1} on {2} \n level {3} - {4}\n\u200B",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Sortie",
"[{0}] Worldstate - Arbitration": "[{0}] Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Alerts",
"[{0}] Nightwave": "[{0}] Nightwave",
"[{0}] Elite Nightwave": "[{0}] Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Sortie",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Credits",
"{0} {1} on {2}": "{0} {1} on {2}",
Expand Down
12 changes: 6 additions & 6 deletions src/resources/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"{0} | {1} left": "{0} | {1} nos abandonó",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} en {2} \nnivel {3} - {4}",
"[{0}] Worldstate - Arbitration": "[{0}] Estado Mundial - Arbitraje",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Alerta",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Nightwave elite",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Invasión",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Fisura del vacío",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Incursión",
"[{0}] Worldstate - Alerts": "[{0}] Alerta",
"[{0}] Worldstate - Nightwave": "[{0}] Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Nightwave elite",
"[{0}] Worldstate - Invasions": "[{0}] Invasión",
"[{0}] Worldstate - Fissures": "[{0}] Fisura del vacío",
"[{0}] Worldstate - Sortie": "[{0}] Incursión",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} créditos",
"{0} {1} on {2}": "{0} {1} en {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/fr.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | {1} restants",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} sur {2} \n niveau {3} - {4}",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Sortie",
"[{0}] Worldstate - Arbitration": "[{0}] Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Sortie",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Credits",
"{0} {1} on {2}": "{0} {1} on {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/it.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | {1} left",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} on {2} \n level {3} - {4}\n",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Sortie",
"[{0}] Worldstate - Arbitration": "[{0}] Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Sortie",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Credits",
"{0} {1} on {2}": "{0} {1} on {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/ko.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | {1} 남음",
"{0} {1} on {2} \n level {3} - {4}\n​": "{2} 의 {0} {1}\n 레벨 {3} - {4}\n",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - 중재",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - 얼럿",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - 나이트웨이브",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - 엘리트 나이트웨이브",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - 침공",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - 유물",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - 출격",
"[{0}] Worldstate - Arbitration": "[{0}] 중재",
"[{0}] Worldstate - Alerts": "[{0}] 얼럿",
"[{0}] Worldstate - Nightwave": "[{0}] 나이트웨이브",
"[{0}] Worldstate - Elite Nightwave": "[{0}] 엘리트 나이트웨이브",
"[{0}] Worldstate - Invasions": "[{0}] 침공",
"[{0}] Worldstate - Fissures": "[{0}] 유물",
"[{0}] Worldstate - Sortie": "[{0}] 출격",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} 크레딧",
"{0} {1} on {2}": "{2} 의 {0} {1}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/pl.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | {1} left",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} on {2} \n level {3} - {4}\n",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Sortie",
"[{0}] Worldstate - Arbitration": "[{0}] Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Alerts",
"[{0}] Worldstate - Nightwave": "[{0}] Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Elite Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Invasions",
"[{0}] Worldstate - Fissures": "[{0}] Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Sortie",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Credits",
"{0} {1} on {2}": "{0} {1} on {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/pt.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | {1} saiu",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} em {2} \n nível {3} - {4}",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Alertas",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Nightwave Elite",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Invasões",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Fissuras",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Incursão",
"[{0}] Worldstate - Arbitration": "[{0}] Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Alertas",
"[{0}] Worldstate - Nightwave": "[{0}] Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Nightwave Elite",
"[{0}] Worldstate - Invasions": "[{0}] Invasões",
"[{0}] Worldstate - Fissures": "[{0}] Fissuras",
"[{0}] Worldstate - Sortie": "[{0}] Incursão",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Créditos",
"{0} {1} on {2}": "{0} {1} em {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/ru.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | осталось {1}",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} на {2} \n уровни {3} - {4}\n",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Арбитраж",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Тревоги",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Ночная Волна",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Ночная Волна Элитные",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - Вторжения",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Разрывы Бездны",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Вылазка",
"[{0}] Worldstate - Arbitration": "[{0}] Арбитраж",
"[{0}] Worldstate - Alerts": "[{0}] Тревоги",
"[{0}] Worldstate - Nightwave": "[{0}] Ночная Волна",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Ночная Волна Элитные",
"[{0}] Worldstate - Invasions": "[{0}] Вторжения",
"[{0}] Worldstate - Fissures": "[{0}] Разрывы Бездны",
"[{0}] Worldstate - Sortie": "[{0}] Вылазка",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Кредитов",
"{0} {1} on {2}": "{0} {1} на {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/tr.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | {1} sol",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} ile {2} \n seviye {3} - {4}\n",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - Uyarılar",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - Elit Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - İstila",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - Void Çatlağı",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - Taarruz",
"[{0}] Worldstate - Arbitration": "[{0}] Arbitration",
"[{0}] Worldstate - Alerts": "[{0}] Uyarılar",
"[{0}] Worldstate - Nightwave": "[{0}] Nightwave",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Elit Nightwave",
"[{0}] Worldstate - Invasions": "[{0}] İstila",
"[{0}] Worldstate - Fissures": "[{0}] Void Çatlağı",
"[{0}] Worldstate - Sortie": "[{0}] Taarruz",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} Krediler",
"{0} {1} on {2}": "{0} {1} ile {2}",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/locales/zh.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"{0} | {1} left": "{0} | 剩下 {1}",
"{0} {1} on {2} \n level {3} - {4}\n​": "{0} {1} 在 {2} \n 等級 {3} - {4}\n",
"[{0}] Worldstate - Arbitration": "[{0}] Worldstate - 仲裁",
"[{0}] Worldstate - Alerts": "[{0}] Worldstate - 警報",
"[{0}] Worldstate - Nightwave": "[{0}] Worldstate - 午夜電波",
"[{0}] Worldstate - Elite Nightwave": "[{0}] Worldstate - 菁英午夜電波",
"[{0}] Worldstate - Invasions": "[{0}] Worldstate - 入侵",
"[{0}] Worldstate - Fissures": "[{0}] Worldstate - 虛空裂縫",
"[{0}] Worldstate - Sortie": "[{0}] Worldstate - 突擊",
"[{0}] Worldstate - Arbitration": "[{0}] 仲裁",
"[{0}] Worldstate - Alerts": "[{0}] 警報",
"[{0}] Worldstate - Nightwave": "[{0}] 午夜電波",
"[{0}] Worldstate - Elite Nightwave": "[{0}] 菁英午夜電波",
"[{0}] Worldstate - Invasions": "[{0}] 入侵",
"[{0}] Worldstate - Fissures": "[{0}] 虛空裂縫",
"[{0}] Worldstate - Sortie": "[{0}] 突擊",
"[{0}] {1}": "[{0}] {1}",
"{0} Credits": "{0} 現金",
"{0} {1} on {2}": "{0} {1} 在 {2}",
Expand Down

0 comments on commit 3796d07

Please sign in to comment.