-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
38 lines (31 loc) · 984 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import 'reflect-metadata';
import { emitKeypressEvents, Key } from 'readline';
import { Client } from 'discord.js';
import { Rcon } from 'rcon-client';
import { container } from 'tsyringe';
import { TSBDevServerBot } from '@/discord/TSBDevServerBot';
import { Config } from '@/Config';
const config = container.resolve(Config);
container.register(Client, { useClass: Client });
container.register(Rcon, {
useValue: new Rcon({
host: config.Rcon.host,
port: config.Rcon.port,
password: config.Rcon.password
})
});
const tsbDevServerBot = container.resolve(TSBDevServerBot);
tsbDevServerBot.Launch();
// `Ctrl+C` に割り込む
emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on('keypress', async (_key: string, keyData: Key) => {
if (keyData.ctrl && keyData.name === 'c') {
try {
await tsbDevServerBot.Destroy();
}
finally {
process.exit();
}
}
});