ms/packages/plugin/src/interfaces.ts

96 lines
2.3 KiB
TypeScript
Raw Normal View History

import { server, MiaoScriptConsole, event, plugin } from "@ccms/api"
import { injectable, inject, postConstruct } from "@ccms/container"
import { getPluginMetadata } from "./utils"
export namespace interfaces {
@injectable()
export abstract class Plugin implements plugin.Plugin {
public description: plugin.PluginMetadata
public logger: Console
@inject(server.Console)
private Console: MiaoScriptConsole
constructor() {
this.description = getPluginMetadata(this)
}
@postConstruct()
private initialize() {
// @ts-ignore
this.logger = new this.Console(this.description.prefix || this.description.name)
}
public load() { }
public enable() { }
public disable() { }
}
export interface ExecMetadata extends plugin.BaseMetadata {
2020-09-17 09:44:48 +00:00
/**
* this
*/
target?: any
/**
*
*/
executor?: string
}
export interface CommandMetadata extends ExecMetadata {
/**
*
*/
alias?: string[]
/**
*
*/
description?: string
/**
*
*/
paramtypes?: string[]
/**
*
*/
autoMain?: boolean
}
export interface ListenerMetadata extends ExecMetadata {
/**
*
*/
priority?: event.EventPriority
/**
*
*/
ignoreCancel?: boolean
}
export interface ConfigMetadata extends plugin.BaseMetadata {
/**
*
*/
version?: number
/**
*
*/
default?: any
/**
*
*/
variable?: string
/**
* yml
*/
format?: string
/**
* false
*/
autosave?: boolean
/**
*
*/
filename?: string
/**
*
*/
file?: any
}
}