diff --git a/src/CommonFunctions.js b/src/CommonFunctions.js index df03d0db0..398854f7f 100644 --- a/src/CommonFunctions.js +++ b/src/CommonFunctions.js @@ -49,6 +49,7 @@ const trackableEvents = { conclave, deals, cetus: ['cetus.day', 'cetus.night'], + earth: ['earth.day', 'earth.night'], }; const trackableItems = { @@ -64,12 +65,13 @@ const trackableItems = { */ const termToTrackable = (term) => { const cetusCustomTimeRegex = new RegExp('cetus\\.(day|night)\\.[0-1]?[0-9]?[0-9]?', 'ig'); + const earthCustomTimeRegex = new RegExp('cetus\\.(day|night)\\.[0-1]?[0-9]?[0-9]?', 'ig'); const trackable = { events: [], items: [], }; - if (cetusCustomTimeRegex.test(term)) { + if (cetusCustomTimeRegex.test(term) || earthCustomTimeRegex.test(term)) { trackable.events = term; return trackable; } @@ -137,7 +139,7 @@ const trackablesFromParameters = (params) => { return trackables; }; -const eventsOrItems = new RegExp(`cetus\\.day\\.[0-1]?[0-9]?[0-9]|cetus\\.night\\.[0-1]?[0-9]?[0-9]|${eventTypes.join('|')}|${rewardTypes.join('|')}|${opts.join('|')}`, 'ig'); +const eventsOrItems = new RegExp(`earth\\.day\\.[0-1]?[0-9]?[0-9]|earth\\.night\\.[0-1]?[0-9]?[0-9]|cetus\\.day\\.[0-1]?[0-9]?[0-9]|cetus\\.night\\.[0-1]?[0-9]?[0-9]|${eventTypes.join('|')}|${rewardTypes.join('|')}|${opts.join('|')}`, 'ig'); const getRandomWelcome = () => welcomes[Math.floor(Math.random() * welcomes.length)]; diff --git a/src/commands/Settings/Prefix.js b/src/commands/Settings/Prefix.js index 03482826e..d36bff8eb 100644 --- a/src/commands/Settings/Prefix.js +++ b/src/commands/Settings/Prefix.js @@ -18,17 +18,16 @@ class Prefix extends Command { this.requiresAuth = true; } - async run(message) { + async run(message, ctx) { const prefix = message.strippedContent.match(this.regex)[1]; if (!prefix) { - const configuredPrefix = this.settings.getChannelPrefix(message.channel); this.messageManager.embed(message, { title: 'Usage', type: 'rich', color: 0x0000ff, fields: [ { - name: `${configuredPrefix}${this.call} `, + name: `${ctx.prefix}${this.call} `, value: 'Set the channel\'s custom prefix', }, ], diff --git a/src/embeds/EarthCycleEmbed.js b/src/embeds/EarthCycleEmbed.js index 84e97bced..34ef7580b 100644 --- a/src/embeds/EarthCycleEmbed.js +++ b/src/embeds/EarthCycleEmbed.js @@ -20,13 +20,8 @@ class EarthCycleEmbed extends BaseEmbed { this.thumbnail = { url: state.isCetus ? 'https://i.imgur.com/Ph337PR.png' : 'https://i.imgur.com/oR6Sskf.png', }; - this.fields = [ - { - name: '_ _', - value: `Time remaining until ${state.isDay ? 'night' : 'day'}: ${timeDeltaToString(fromNow(new Date(state.expiry)))}` - + `${state.bountyExpiry ? `\nBounties expire in ${timeDeltaToString(fromNow(new Date(state.bountyExpiry)))}` : ''}`, - }, - ]; + this.description = `Time remaining until ${state.isDay ? 'night' : 'day'}: ${timeDeltaToString(fromNow(new Date(state.expiry)))}` + + `${state.bountyExpiry ? `\nBounties expire in ${timeDeltaToString(fromNow(new Date(state.bountyExpiry)))}` : ''}`; this.footer.text = `${state.isDay ? 'Night' : 'Day'} starts `; this.timestamp = new Date(state.expiry); } diff --git a/src/notifications/Notifier.js b/src/notifications/Notifier.js index 26aab570e..bea2794b2 100644 --- a/src/notifications/Notifier.js +++ b/src/notifications/Notifier.js @@ -79,7 +79,7 @@ class Notifier { const ids = await this.getNotifiedIds(platform, this.bot.shardId); // Set up data to notify const acolytesToNotify = newData.persistentEnemies - .filter(e => !ids.includes(e.pid) && e.isDiscovered); + .filter(e => !ids.includes(e.pid)); const alertsToNotify = newData.alerts .filter(a => !ids.includes(a.id) && !a.expired); const baroToNotify = newData.voidTrader && !ids.includes(newData.voidTrader.psId) @@ -110,6 +110,7 @@ class Notifier { const streamsToNotify = newData.news .filter(n => !ids.includes(n.id) && n.stream && n.translations.en); const cetusCycleChange = !ids.includes(newData.cetusCycle.id) && newData.cetusCycle.expiry; + const earthCycleChange = !ids.includes(`earthCycle${new Date(newData.earthCycle).getTime()}`) && newData.earthCycle.expiry; // Concat all notified ids notifiedIds = notifiedIds .concat(newData.alerts.map(a => a.id)) @@ -124,7 +125,8 @@ class Notifier { .concat(newData.sortie ? [newData.sortie.id] : []) .concat(newData.syndicateMissions.map(m => m.id)) .concat(newData.voidTrader ? [`${newData.voidTrader.id}${newData.voidTrader.inventory.length}`] : []) - .concat([newData.cetusCycle.id]); + .concat([newData.cetusCycle.id]) + .concat([`earthCycle${new Date(newData.earthCycle).getTime()}`]); // Send all notifications await this.updateNotified(notifiedIds, platform); @@ -164,6 +166,7 @@ class Notifier { newData.cetusCycle.bountyExpiry = ostron.expiry; } await this.sendCetusCycle(newData.cetusCycle, platform, cetusCycleChange); + await this.sendEarthCycle(newData.earthCycle, platform, earthCycleChange); this.sendUpdates(updatesToNotify, platform); await this.sendAlerts(alertsToNotify, platform); } @@ -190,7 +193,7 @@ class Notifier { await Promise.all(newAcolytes.map(async a => this.broadcaster.broadcast(new EnemyEmbed( this.bot, [a], platform, - ), platform, 'enemies', null, 3600000))); + ), platform, `enemies${a.isDiscovered ? '' : '.departed'}`, null, 3600000))); } async sendAlerts(newAlerts, platform) { @@ -367,6 +370,15 @@ class Notifier { platform, type, null, fromNow(newCetusCycle.expiry), ); } + + async sendEarthCycle(newEarthCycle, platform, cetusCycleChange) { + const minutesRemaining = cetusCycleChange ? '' : `.${Math.round(fromNow(newEarthCycle.expiry) / 60000)}`; + const type = `earth.${newEarthCycle.isDay ? 'day' : 'night'}${minutesRemaining}`; + await this.broadcaster.broadcast( + new EarthCycleEmbed(this.bot, newEarthCycle), + platform, type, null, fromNow(newEarthCycle.expiry), + ); + } } module.exports = Notifier; diff --git a/src/resources/trackables.json b/src/resources/trackables.json index 425137b89..b8f579d05 100644 --- a/src/resources/trackables.json +++ b/src/resources/trackables.json @@ -54,6 +54,7 @@ "deals.featured", "deals.popular", "enemies", + "enemies.departed", "conclave.weeklies", "conclave.dailies", "syndicate.arbiters", @@ -67,6 +68,8 @@ "streams", "cetus.day", "cetus.night", + "earth.day", + "earth.night", "syndicate.ostrons", "syndicate.assassins", "operations", @@ -175,7 +178,8 @@ "fissures.assault", "fissures.evacuation", "fissures", - "cetus" + "cetus", + "earth" ], "fissures":[ "fissures.t1.excavation", diff --git a/src/settings/DatabaseQueries/SettingsQueries.js b/src/settings/DatabaseQueries/SettingsQueries.js index c32e669d6..74fa9fdb8 100644 --- a/src/settings/DatabaseQueries/SettingsQueries.js +++ b/src/settings/DatabaseQueries/SettingsQueries.js @@ -122,14 +122,14 @@ class SettingsQueries { * Resets the custom prefix for this guild to the bot's globally configured prefix * @param {Guild} guild The Discord guild for which to set the response setting * @param {string} setting Name of the setting to set - * @param {string|boolean} val value of the setting to be set + * @param {string|boolean} value value of the setting to be set * @returns {Promise} */ - async setGuildSetting(guild, setting, val) { + async setGuildSetting(guild, setting, value) { if (typeof setting === 'undefined' || typeof value === 'undefined') return false; const promises = []; - guild.channels.array().forEach((channel) => { - promises.push(this.setChannelSetting(channel, setting, val)); + guild.channels.forEach((channel) => { + promises.push(this.setChannelSetting(channel, setting, value)); }); return Promise.all(promises); } @@ -142,7 +142,7 @@ class SettingsQueries { */ async deleteGuildSetting(guild, setting) { const promises = []; - guild.channels.array().forEach((channel) => { + guild.channels.forEach((channel) => { promises.push(this.deleteChannelSetting(channel, setting)); }); return Promise.all(promises);