Skip to content

Commit

Permalink
Added primary property to distinguish between important and not impor…
Browse files Browse the repository at this point in the history
…tant stuff while preparing BGS reports
  • Loading branch information
Sayak Mukhopadhyay committed Jul 13, 2017
1 parent 7f84f47 commit 220c990
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/db/interfaces/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface IGuild {
created_at: Date,
updated_at: Date,
monitor_systems: [{
primary: boolean,
system_name: string,
system_pos: {
x: number,
Expand All @@ -31,6 +32,7 @@ export interface IGuild {
}
}],
monitor_factions: [{
primary: boolean,
faction_name: string
}]
}
2 changes: 2 additions & 0 deletions src/db/schemas/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export let guildSchema: Schema = new Schema({
updated_at: Date,
monitor_systems: [{
_id: false,
primary: Boolean,
system_name: String,
system_pos: {
x: Number,
Expand All @@ -41,6 +42,7 @@ export let guildSchema: Schema = new Schema({
}],
monitor_factions: [{
_id: false,
primary: Boolean,
faction_name: String
}]
});
7 changes: 6 additions & 1 deletion src/modules/discord/commands/monitorFactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MonitorFactions {
}
}

add(message: discord.Message, argsArray: string[]) {
add(message: discord.Message, argsArray: string[], primary: boolean = false) {
Access.has(message.member, [Access.ADMIN, Access.BGS, Access.FORBIDDEN])
.then(() => {
if (argsArray.length >= 2) {
Expand Down Expand Up @@ -82,6 +82,7 @@ export class MonitorFactions {
{ guild_id: guildId },
{
updated_at: new Date(),
primary: primary,
$addToSet: { monitor_factions: monitorFactions }
})
.then(guild => {
Expand Down Expand Up @@ -135,6 +136,10 @@ export class MonitorFactions {
})
}

addprimary(message: discord.Message, argsArray: string[]) {
this.add(message, argsArray, true);
}

remove(message: discord.Message, argsArray: string[]) {
Access.has(message.member, [Access.ADMIN, Access.BGS, Access.FORBIDDEN])
.then(() => {
Expand Down
7 changes: 6 additions & 1 deletion src/modules/discord/commands/monitorSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MonitorSystems {
}
}

add(message: discord.Message, argsArray: string[]) {
add(message: discord.Message, argsArray: string[], primary: boolean = false) {
Access.has(message.member, [Access.ADMIN, Access.BGS, Access.FORBIDDEN])
.then(() => {
if (argsArray.length >= 2) {
Expand Down Expand Up @@ -87,6 +87,7 @@ export class MonitorSystems {
{ guild_id: guildId },
{
updated_at: new Date(),
primary: primary,
$addToSet: { monitor_systems: monitorSystems }
})
.then(guild => {
Expand Down Expand Up @@ -140,6 +141,10 @@ export class MonitorSystems {
})
}

addprimary(message: discord.Message, argsArray: string[]) {
this.add(message, argsArray, true);
}

remove(message: discord.Message, argsArray: string[]) {
Access.has(message.member, [Access.ADMIN, Access.BGS, Access.FORBIDDEN])
.then(() => {
Expand Down

0 comments on commit 220c990

Please sign in to comment.