Skip to content

Commit

Permalink
Merge pull request #7 from PoloLacoste/develop
Browse files Browse the repository at this point in the history
Adding server status + fix security issue
  • Loading branch information
PoloLacoste authored Aug 16, 2021
2 parents 6d824ac + 5300ffc commit 39835d3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/commands/status.ts
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));
}
}
4 changes: 3 additions & 1 deletion src/discord/app-discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -16,7 +17,8 @@ import { Stats } from '../commands/stats';
Playtime,
Level,
Rank,
Stats
Stats,
Status,
]
})
abstract class AppDiscord {
Expand Down

0 comments on commit 39835d3

Please sign in to comment.