-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from PoloLacoste/develop
Adding server status + fix security issue
- Loading branch information
Showing
4 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters