Skip to content

Commit

Permalink
Merge pull request #3 from SayakMukhopadhyay/wip
Browse files Browse the repository at this point in the history
BGS Report completed
  • Loading branch information
SayakMukhopadhyay authored Jul 18, 2017
2 parents 749f5c2 + 2a82ca6 commit 220c9cf
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/db/interfaces/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IGuild {
monitor_systems: [{
primary: boolean,
system_name: string,
system_name_lower: string,
system_pos: {
x: number,
y: number,
Expand All @@ -33,6 +34,7 @@ export interface IGuild {
}],
monitor_factions: [{
primary: boolean,
faction_name: string
faction_name: string,
faction_name_lower: string
}]
}
4 changes: 3 additions & 1 deletion src/db/schemas/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export let guildSchema: Schema = new Schema({
_id: false,
primary: Boolean,
system_name: String,
system_name_lower: String,
system_pos: {
x: Number,
y: Number,
Expand All @@ -43,6 +44,7 @@ export let guildSchema: Schema = new Schema({
monitor_factions: [{
_id: false,
primary: Boolean,
faction_name: String
faction_name: String,
faction_name_lower: String
}]
});
3 changes: 2 additions & 1 deletion src/modules/discord/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as discord from 'discord.js';
import { DiscordSecrets } from '../../secrets';
import { Responses } from './responseDict';
import { Hi, Help, MyGuild, BGSRole, AdminRoles, ForbiddenRoles, BGSChannel, MonitorSystems, MonitorFactions, SystemStatus, FactionStatus } from './commands';
import { Hi, Help, MyGuild, BGSRole, AdminRoles, ForbiddenRoles, BGSChannel, MonitorSystems, MonitorFactions, SystemStatus, FactionStatus, BGSReport } from './commands';

export class DiscordClient {
public client: discord.Client;
Expand Down Expand Up @@ -77,5 +77,6 @@ export class DiscordClient {
this.commandsMap.set("monitorfactions", MonitorFactions);
this.commandsMap.set("systemstatus", SystemStatus);
this.commandsMap.set("factionstatus", FactionStatus);
this.commandsMap.set("bgsreport", BGSReport);
}
}
280 changes: 280 additions & 0 deletions src/modules/discord/commands/bgsReport.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/modules/discord/commands/factionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export class FactionStatus {
factionDetail += `Recovering States : ${recoveringStates}`;
resolve([systemName, factionDetail]);
}
} else {
reject(error);
}
})
}));
Expand Down
1 change: 1 addition & 0 deletions src/modules/discord/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export * from './monitorSystems';
export * from './monitorFactions';
export * from './systemStatus';
export * from './factionStatus';
export * from './bgsReport';
5 changes: 3 additions & 2 deletions src/modules/discord/commands/monitorFactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class MonitorFactions {
let factionName = responseObject[0].name;
let factionNameLower = responseObject[0].name_lower;
let monitorFactions = {
faction_name: factionNameLower,
faction_name: factionName,
faction_name_lower: factionNameLower,
primary: primary,
}
this.db.model.guild.findOneAndUpdate(
Expand Down Expand Up @@ -129,7 +130,7 @@ export class MonitorFactions {
{ guild_id: guildId },
{
updated_at: new Date(),
$pull: { monitor_factions: { faction_name: factionName } }
$pull: { monitor_factions: { faction_name_lower: factionName } }
})
.then(guild => {
if (guild) {
Expand Down
5 changes: 3 additions & 2 deletions src/modules/discord/commands/monitorSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class MonitorSystems {
let systemName = responseObject[0].name;
let systemNameLower = responseObject[0].name_lower;
let monitorSystems = {
system_name: systemNameLower,
system_name: systemName,
system_name_lower: systemNameLower,
primary: primary,
system_pos: {
x: responseObject[0].x,
Expand Down Expand Up @@ -134,7 +135,7 @@ export class MonitorSystems {
{ guild_id: guildId },
{
updated_at: new Date(),
$pull: { monitor_systems: { system_name: systemName } }
$pull: { monitor_systems: { system_name_lower: systemName } }
})
.then(guild => {
if (guild) {
Expand Down
4 changes: 3 additions & 1 deletion src/modules/discord/commands/systemStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export class SystemStatus {
}
resolve([factionName, factionDetail]);
}
} else {
reject(error);
}
})
}));
Expand All @@ -159,7 +161,7 @@ export class SystemStatus {
.then(fields => {
fields.forEach(field => {
embed.addField(field[0], field[1]);
})
});
embed.setTimestamp(new Date());
message.channel.send({ embed })
.catch(err => {
Expand Down

0 comments on commit 220c9cf

Please sign in to comment.