cubbot/src/app.ts

27 lines
727 B
TypeScript
Raw Normal View History

2020-04-16 20:22:57 +00:00
import * as mc from 'minecraft-protocol'
import Env from './core/Env'
2020-04-17 14:26:33 +00:00
import { logger } from './core/logger'
import modulesTypes from './modules'
2020-04-16 20:22:57 +00:00
export default () => {
logger.warn('Cubbot start')
const client = mc.createClient({
2020-04-17 14:26:33 +00:00
host: Env.get('CORE_HOST'),
2020-04-16 20:22:57 +00:00
password: Env.orFail('CORE_PASS'),
2020-04-17 14:26:33 +00:00
port: Env.getAs('CORE_PORT', Number.parseInt),
2020-04-16 20:22:57 +00:00
username: Env.orFail('CORE_USER'),
})
client.on('connect', () => {
2020-04-17 14:26:33 +00:00
logger.trace('Connected')
2020-04-16 20:22:57 +00:00
})
client.on('disconnect', packet => {
2020-04-17 14:26:33 +00:00
logger.warn('Disconnected ' + packet.reason)
2020-04-16 20:22:57 +00:00
})
client.on('login', () => {
2020-04-17 14:26:33 +00:00
logger.trace('Logged')
2020-04-16 20:22:57 +00:00
})
2020-04-17 14:26:33 +00:00
const modules = modulesTypes.map(t => new t(client))
}