-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fomorian/Razorback construction and Events #125
Changes from 9 commits
3d78ff7
d5499f2
b61d0cd
7b7cda0
dd10bd2
cb6b80c
658e157
fde711a
d8e0f4b
bb1b8d1
bc88b3d
9b7653e
a47c012
6a86c7c
9e34fbe
55ac182
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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].getDataJson(); | ||
await this.messageManager.embed(message, new EventEmbed(this.bot, | ||
ws.constructionProgress, platform.toUpperCase()), true, true); | ||
return this.messageManager.statuses.SUCCESS; | ||
} | ||
} | ||
|
||
module.exports = Construction; |
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'); | ||
const ws = await this.bot.caches[platform].getDataJson(); | ||
if (ws.events.length > 0) { | ||
const results = []; | ||
ws.events.forEach(event => { | ||
results.push(this.messageManager.embed(message, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 8 spaces but found 10. (indent) |
||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing spaces not allowed. (no-trailing-spaces) |
||
undefined, platform.toUpperCase()), true, true); | ||
return this.messageManager.statuses.FAILURE; | ||
} | ||
} | ||
|
||
module.exports = Event; |
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}] Construction Status:`, | ||
value: '```' + | ||
`Razorback: ${constructionProgress.razorbackProgress}` + | ||
`Fomorian: ${constructionProgress.fomorianProgress}` + | ||
`Unknown: ${constructionProgress.unknwonProgress}` + | ||
'```', | ||
}]; | ||
} | ||
} | ||
|
||
module.exports = ConstructionEmbed; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,34 @@ | ||
'use strict'; | ||
|
||
const BaseEmbed = require('./BaseEmbed.js'); | ||
|
||
/** | ||
* Generates fissure embeds | ||
*/ | ||
class EventEmbed extends BaseEmbed { | ||
/** | ||
* @param {Genesis} bot - An instance of Genesis | ||
* @param {Array.<Event>} events - The fissures to be included in the embed | ||
*/ | ||
constructor(bot, events) { | ||
super(); | ||
|
||
if (events.length < 2) { | ||
this.title = 'Worldstate - Events'; | ||
this.description = 'Events'; | ||
} | ||
|
||
if (events.length > 1) { | ||
this.fields = events.map(e => ({ | ||
name: `${e.description}`, | ||
value: `Takes place on: ${e.concurrentNodes.join(', ')}\nRewards: ${e.rewards.join(', ')}`, | ||
})); | ||
} else if (events.length === 0) { | ||
this.fields = { | ||
name: 'Currently no events', | ||
value: '_ _', | ||
}; | ||
} else { | ||
const e = events[0]; | ||
this.title = 'Event! '; | ||
this.description = `${e.description} against ${e.faction}`; | ||
this.fields = [ | ||
{ | ||
name: 'Rewards', | ||
value: e.rewards.join('\n'), | ||
inline: true, | ||
}, | ||
{ | ||
name: 'Nodes', | ||
value: `${e.concurrentNodes.join('\n')}\n${e.node ? e.node : ''}\n${e.victimNode ? e.victimNode : ''}`, | ||
inline: true, | ||
}, | ||
]; | ||
this.footer.text = e.toolTip ? e.toolTip : this.footer.text; | ||
} | ||
|
||
this.color = events.length > 2 ? 0x00ff00 : 0xff0000; | ||
this.thumbnail = { | ||
url: 'https://i.imgur.com/EfIRu6v.png', | ||
}; | ||
} | ||
} | ||
|
||
module.exports = EventEmbed; | ||
'use strict'; | ||
|
||
const BaseEmbed = require('./BaseEmbed.js'); | ||
|
||
/** | ||
* Generates daily deal embeds | ||
*/ | ||
class EventEmbed extends BaseEmbed { | ||
/** | ||
* @param {Genesis} bot - An instance of Genesis | ||
* @param {Event} event - The deal to be included in the embed | ||
* @param {string} platform - The platform the event is for | ||
*/ | ||
constructor(bot, event, platform) { | ||
super(); | ||
|
||
this.color = 0xfdec96; | ||
|
||
if (event) { | ||
this.title = `[${platform}] ${event.description}`; | ||
this.fields = []; | ||
|
||
if (event.victimNode) { | ||
this.fields.push({name: '_ _', value: `Defend ${event.victimNode} by attacking the ${event.faction} at ${event.node}.` }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 8 spaces but found 10. (indent) |
||
} | ||
this.fields.push({ name: 'Rewards', value: event.rewards.map(reward => reward.asString).join('; ') }); | ||
this.fields.push({ name: 'Completion Score', value: String(event.maximumScore) }); | ||
} else { | ||
this.title = 'No Current Events'; | ||
} | ||
} | ||
} | ||
|
||
module.exports = EventEmbed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected parentheses around arrow function argument having a body with curly braces. (arrow-parens)