mirai-node-typescript
v0.0.4
Published
node mirai typescript
Downloads
6
Readme
mirai-node-typescript
work environment
mirai-console-wrapper-0.1.3-all.jar
mirai-api-http-v1.2.3.jar
how to use mirai
install
yarn add mirai-node-typescript
listen callback
mirai.onListenMessage({
// msg
msgCallback(msg) {
// do something
console.log(msg)
},
// event
eventCallback(event) {
// do something
console.log(event)
}
})
use in typescript
import Mirai from 'mirai-node-typescript'
const mirai = new Mirai() // auto connect
use in js
const Mirai = require('mirai-node-typescript').default
const mirai = new Mirai() // auto connect
use with origin code
install ts-node and tsconfig-paths
yarn add ts-node
yarn add tsconfig-paths
add script in package.json
"scripts": {
"server": "ts-node --project ./tsconfig.json -r tsconfig-paths/register ./src/index.ts",
"dev": "ts-node-dev --project ./tsconfig.json -r tsconfig-paths/register ./src/index.ts"
},
demo tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"module": "commonjs",
"outDir": "./lib/",
"rootDir": "./src",
"target": "es6",
"lib": [
"es2019"
],
"declaration": true,
"declarationDir": "./lib",
"allowJs": true,
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"esModuleInterop": true,
"sourceMap": true,
"resolveJsonModule": true,
"typeRoots": [
"typings",
"node_modules/@types"
],
"baseUrl": "."
},
"include": [
"./src",
"typings"
],
"exclude": [
"node_modules"
]
}