From 62b51c9cdabec5aafe17de7f0dc23d5f7a00aca7 Mon Sep 17 00:00:00 2001 From: JM REMEUR Date: Mon, 16 Aug 2021 18:47:28 +0200 Subject: [PATCH 1/3] fix security issue --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index f0885ac..eccd82a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2260,9 +2260,9 @@ } }, "node_modules/path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "node_modules/path-type": { @@ -4759,9 +4759,9 @@ "dev": true }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-type": { From ec25857f676824e89d3083809df96d65ab3fa506 Mon Sep 17 00:00:00 2001 From: JM REMEUR Date: Mon, 16 Aug 2021 19:07:06 +0200 Subject: [PATCH 2/3] added status server command --- src/commands/status.ts | 26 ++++++++++++++++++++++++++ src/discord/app-discord.ts | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/commands/status.ts diff --git a/src/commands/status.ts b/src/commands/status.ts new file mode 100644 index 0000000..6b4af0f --- /dev/null +++ b/src/commands/status.ts @@ -0,0 +1,26 @@ +import { Logger } from 'tslog'; +import { container } from 'tsyringe'; +import { Command, CommandMessage } from '@typeit/discord'; +import { R6Service } from 'r6-api-caching'; +import { formatMessage } from '../utils'; + +export abstract class Status { + + private readonly r6Service = container.resolve(R6Service); + private readonly logger = container.resolve(Logger); + + @Command('status') + async status(command: CommandMessage) { + this.logger.info(`Sent server status message to ${command.author.username}`); + + const serverStatus = await this.r6Service.getServersStatus(); + const response = ['server status :']; + + for (const server of serverStatus) { + const online = server.status === 'Online' ? '🟢' : '🔴'; + response.push(`${online} : ${server.name}`); + } + + command.reply(formatMessage(response)); + } +} diff --git a/src/discord/app-discord.ts b/src/discord/app-discord.ts index 29d0c9f..a12c2c9 100644 --- a/src/discord/app-discord.ts +++ b/src/discord/app-discord.ts @@ -7,6 +7,7 @@ import { Playtime } from '../commands/playtime'; import { Link } from '../commands/link'; import { Rank } from '../commands/rank'; import { Stats } from '../commands/stats'; +import { Status } from '../commands/status'; @Discord('!', { import: [ @@ -16,7 +17,8 @@ import { Stats } from '../commands/stats'; Playtime, Level, Rank, - Stats + Stats, + Status, ] }) abstract class AppDiscord { From 5300ffc4ab658e91bed3bed4b1be2e70dae880eb Mon Sep 17 00:00:00 2001 From: JM REMEUR Date: Mon, 16 Aug 2021 19:09:10 +0200 Subject: [PATCH 3/3] updated readme --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 4c2141b..f07d5c4 100644 --- a/README.md +++ b/README.md @@ -192,4 +192,14 @@ Optional arguments : - platform : To specify the platform the account is on (default `uplay`, `uplay` (pc), `xbl` (Xbox Live) or `psn` (PlayStation Network)) +### 🟢 !status + +This command will return the status of all the servers. + +Example : + +``` +!status +``` + ## 🌟 You are all set! You have a problem ? Please open an issue