Skip to content

Commit

Permalink
Fomorian/Razorback construction and Events (#125)
Browse files Browse the repository at this point in the history
* adding embeds

* Add commands for previously added embeds

* fix bad parentheses

* fix parens

* fix indents

* fix indents

* fix comma and syntax (construction didn't exist)

* fix some indents and line length

* fix line length

* fix line length

* stickler fixes

* fix indentation

* fix indents

* Update EventEmbed.js

* add health to event

* add platform to notifications and commands
  • Loading branch information
TobiTenno authored Sep 20, 2017
1 parent cfdda08 commit 04165a6
Show file tree
Hide file tree
Showing 32 changed files with 236 additions and 140 deletions.
3 changes: 1 addition & 2 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ class Genesis {
'GUILD_MEMBER_REMOVE', 'GUILD_BAN_ADD', 'GUILD_BAN_REMOVE',
'CHANNEL_PINS_UPDATE', 'MESSAGE_UPDATE', 'MESSAGE_DELETE_BULK',
'MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE', 'MESSAGE_REACTION_REMOVE_ALL', 'USER_NOTE_UPDATE',
'USER_SETTINGS_UPDATE', 'PRESENCE_UPDATE', 'TYPING_START', 'RELATIONSHIP_ADD',
'RELATIONSHIP_REMOVE',
'USER_SETTINGS_UPDATE', 'TYPING_START', 'RELATIONSHIP_ADD', 'RELATIONSHIP_REMOVE',
],
});

Expand Down
5 changes: 3 additions & 2 deletions src/commands/Worldstate/Alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class Alerts extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const alerts = ws.alerts.filter(a => !a.expired);
await this.messageManager.embed(message, new AlertEmbed(this.bot, alerts), true, false);
await this.messageManager.embed(message,
new AlertEmbed(this.bot, alerts, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Baro.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Baro extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
await this.messageManager.embed(message,
new VoidTraderEmbed(this.bot, ws.voidTrader), true, false);
new VoidTraderEmbed(this.bot, ws.voidTrader, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/commands/Worldstate/Construction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

const Command = require('../../Command.js');
const EventEmbed = require('../../embeds/ConstructionEmbed.js');

/**
* Displays the current simaris target
*/
class Construction extends Command {
/**
* Constructs a callable command
* @param {Genesis} bot The bot object
*/
constructor(bot) {
super(bot, 'warframe.worldstate.construction', 'construction', 'Display current construction progress.');
this.regex = new RegExp(`^${this.call}(?:\\s+on\\s+([pcsxb14]{2,3}))?$`, 'i');
}

async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings
.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
await this.messageManager.embed(message, new EventEmbed(this.bot,
ws.constructionProgress, platform.toUpperCase()), true, true);
return this.messageManager.statuses.SUCCESS;
}
}

module.exports = Construction;
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Darvo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Darvo extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const deal = ws.dailyDeals[0];
await this.messageManager.embed(message, new DarvoEmbed(this.bot, deal), true, false);
await this.messageManager.embed(message, new DarvoEmbed(this.bot, deal, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Enemies.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Enemies extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
await this.messageManager.embed(message,
new EnemyEmbed(this.bot, ws.persistentEnemies), true, false);
new EnemyEmbed(this.bot, ws.persistentEnemies, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
39 changes: 39 additions & 0 deletions src/commands/Worldstate/Event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

const Command = require('../../Command.js');
const EventEmbed = require('../../embeds/EventEmbed.js');

/**
* Displays the current event statuses
*/
class Event extends Command {
/**
* Constructs a callable command
* @param {Genesis} bot The bot object
*/
constructor(bot) {
super(bot, 'warframe.worldstate.events', 'events', 'Display current events.');
this.regex = new RegExp(`^${this.call}(?:\\s+on\\s+([pcsxb14]{2,3}))?$`, 'i');
}

async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = (platformParam || await this.bot.settings
.getChannelSetting(message.channel, 'platform')).toLowerCase();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
if (ws.events.length > 0) {
const results = [];
ws.events.forEach((event) => {
results.push(this.messageManager.embed(message,
new EventEmbed(this.bot, event, platform.toUpperCase()), true, true));
});
await Promise.all(results);
return this.messageManager.statuses.SUCCESS;
}
await this.messageManager.embed(message, new EventEmbed(this.bot,
undefined, platform.toUpperCase()), true, true);
return this.messageManager.statuses.FAILURE;
}
}

module.exports = Event;
4 changes: 2 additions & 2 deletions src/commands/Worldstate/FeaturedDeal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class FeaturedDeal extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const sales = ws.flashSales.filter(popularItem => popularItem.isFeatured);
await this.messageManager.embed(message,
new SalesEmbed(this.bot, sales), true, false);
new SalesEmbed(this.bot, sales, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Fissures.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class Fissures extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const fissures = ws.fissures.sort((a, b) => a.tierNum > b.tierNum);
await this.messageManager.embed(message,
new FissureEmbed(this.bot, fissures), true, false);
new FissureEmbed(this.bot, fissures, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Invasions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class Invasions extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const invasions = ws.invasions.filter(i => !i.completed);
await this.messageManager.embed(message,
new InvasionEmbed(this.bot, invasions), true, false);
new InvasionEmbed(this.bot, invasions, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/Worldstate/News.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class News extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const news = ws.news.filter(n => !n.update && !n.primeAccess);
await this.messageManager.embed(message, new NewsEmbed(this.bot, news), true, false);
await this.messageManager.embed(message,
new NewsEmbed(this.bot, news, undefined, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/Worldstate/PopularSale.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class PopularDeal extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const sales = ws.flashSales.filter(popularItem => popularItem.isPopular);
await this.messageManager.embed(message, new SalesEmbed(this.bot, sales), true, false);
await this.messageManager.embed(message,
new SalesEmbed(this.bot, sales, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/PrimeAccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class PrimeAccess extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const news = ws.news.filter(n => n.primeAccess);
await this.messageManager.embed(message, new PrimeAccessEmbed(this.bot, news, 'primeaccess'), true, false);
await this.messageManager.embed(message, new PrimeAccessEmbed(this.bot, news, 'primeaccess', platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/Worldstate/Simaris.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class Simaris extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const simaris = ws.simaris;
await this.messageManager.embed(message, new SimarisEmbed(this.bot, simaris), true, false);
await this.messageManager.embed(message,
new SimarisEmbed(this.bot, simaris, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Sorties.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class Sorties extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const sortie = ws.sortie;
if (sortie.expired) {
await this.messageManager.sendMessage(message, 'There is currently no sortie', true, true);
return this.messageManager.statuses.FAILURE;
}
const embed = new SortieEmbed(this.bot, sortie);
const embed = new SortieEmbed(this.bot, sortie, platform);
try {
const articles = await warframe.getSearchList({ query: sortie.boss, limit: 1 });
const details = await warframe.getArticleDetails({ ids: articles.items.map(i => i.id) });
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Syndicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class Syndicates extends Command {
platformParam = param1;
}
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
await this.messageManager.embed(message, new SyndicateEmbed(this.bot,
ws.syndicateMissions, syndicate), true, false);
ws.syndicateMissions, syndicate, platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Worldstate/Updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Updates extends Command {
async run(message) {
const platformParam = message.strippedContent.match(this.regex)[1];
const platform = platformParam || await this.bot.settings.getChannelSetting(message.channel, 'platform');
const ws = await this.bot.caches[platform].getDataJson();
const ws = await this.bot.caches[platform.toLowerCase()].getDataJson();
const news = ws.news.filter(n => n.update);
await this.messageManager.embed(message, new UpdateEmbed(this.bot, news, 'update'), true, false);
await this.messageManager.embed(message, new UpdateEmbed(this.bot, news, 'update', platform), true, false);
return this.messageManager.statuses.SUCCESS;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/embeds/AlertEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class AlertEmbed extends BaseEmbed {
/**
* @param {Genesis} bot - An instance of Genesis
* @param {Array.<Alert>} alerts - The alerts to be included in the embed
* @param {string} platform - platform
*/
constructor(bot, alerts) {
constructor(bot, alerts, platform) {
super();

this.thumbnail = {
Expand All @@ -23,11 +24,10 @@ class AlertEmbed extends BaseEmbed {
value: `${a.mission.faction} ${a.mission.type} on ${a.mission.node}\n` +
`level ${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}`,
}));
this.title = 'Worldstate - Alerts';
this.description = 'Currently in-progress alerts:';
this.title = `[${platform.toUpperCase()}] Worldstate - Alerts`;
} else {
const a = alerts[0];
this.title = a.mission.reward.itemString;
this.title = `[${platform.toUpperCase()}] ${a.mission.reward.itemString}`;
this.url = 'https://ws.warframestat.us/';
this.color = a.mission.reward.color;
this.thumbnail.url = a.mission.reward.thumbnail;
Expand Down
29 changes: 29 additions & 0 deletions src/embeds/ConstructionEmbed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

const BaseEmbed = require('./BaseEmbed.js');

/**
* Generates daily deal embeds
*/
class ConstructionEmbed extends BaseEmbed {
/**
* @param {Genesis} bot - An instance of Genesis
* @param {Construction} constructionProgress - The current construction information
* @param {string} platform - The platform the event is for
*/
constructor(bot, constructionProgress, platform) {
super();

this.color = 0xff6961;
this.fields = [{
name: `[${platform.toUpperCase()}] Construction Status:`,
value: '```' +
`Razorback: ${constructionProgress.razorbackProgress}` +
`Fomorian: ${constructionProgress.fomorianProgress}` +
`Unknown: ${constructionProgress.unknwonProgress}` +
'```',
}];
}
}

module.exports = ConstructionEmbed;
5 changes: 3 additions & 2 deletions src/embeds/DarvoEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ class DarvoEmbed extends BaseEmbed {
/**
* @param {Genesis} bot - An instance of Genesis
* @param {DailyDeal} deal - The deal to be included in the embed
* @param {string} platform - platform
*/
constructor(bot, deal) {
constructor(bot, deal, platform) {
super();

this.color = 0x0000ff;
this.title = 'Darvo Deal';
this.title = `[${platform.toUpperCase()}] Darvo Deal`;
this.thumbnail = {
url: 'http://i.imgur.com/UotylUm.png',
};
Expand Down
5 changes: 3 additions & 2 deletions src/embeds/EarthCycleEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ class EarthCycleEmbed extends BaseEmbed {
/**
* @param {Genesis} bot - An instance of Genesis
* @param {Object} state - The current state of the cycle
* @param {string} platform - platform
*/
constructor(bot, state) {
constructor(bot, state, platform) {
super();

this.color = state.isDay ? 0x00ff00 : 0x000066;
this.title = 'Worldstate - Earth Cycle';
this.title = `[${platform.toUpperCase()}] Worldstate - Earth Cycle`;
this.thumbnail = {
url: 'http://vignette1.wikia.nocookie.net/warframe/images/1/1e/Earth.png',
};
Expand Down
7 changes: 4 additions & 3 deletions src/embeds/EnemyEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ class EnemyEmbed extends BaseEmbed {
/**
* @param {Genesis} bot - An instance of Genesis
* @param {Array.<PersistentEnemy>} enemies - The persistentEnemies to be included in the embed
* @param {string} platform - platform
*/
constructor(bot, enemies) {
constructor(bot, enemies, platform) {
super();

this.thumbnail = {
url: 'http://i.imgur.com/pMRt2Cp.png',
};
this.title = 'Acolytes';
this.title = `[${platform.toUpperCase()}] Acolytes`;
if (enemies.length > 1) {
this.color = enemies.length > 2 ? 0x00ff00 : 0xff0000;
this.fields = enemies.map(e => ({
Expand All @@ -27,7 +28,7 @@ class EnemyEmbed extends BaseEmbed {
}));
} else if (enemies.length === 1) {
const e = enemies[0];
this.title = e.agentType;
this.title = `[${platform.toUpperCase()}] ${e.agentType}`;
this.description = `Enemy ${e.discovered ? 'Discovered' : 'Hiding'}!`;
this.color = 0xaf5b4b;
this.fields = [{ name: '_ _', value: `**${e.discovered ? '' : 'Last '}Discovered At:** ${e.lastDiscoveredAt}` },
Expand Down
Loading

0 comments on commit 04165a6

Please sign in to comment.