- Separated plugin flags for statuses - Disallow access to internal plugin flags in plugin APIs - await `handleError` when plugin throws an error - Added safe guards to prevent initing/starting a plugin twice or when it is not enabled - Call GC after plugin stops - Await plugin init and start before stopping
28 lines
814 B
TypeScript
28 lines
814 B
TypeScript
import { AppStartPerformance } from '@revenge-mod/discord'
|
|
|
|
import { PluginFlags } from '@revenge-mod/plugins'
|
|
import { InternalPluginFlags, registerPlugin } from '@revenge-mod/plugins/_'
|
|
|
|
AppStartPerformance.mark('👊', 'Plugins register')
|
|
|
|
const tsReg = performance.now()
|
|
let tsInit: number
|
|
|
|
registerPlugin(
|
|
{
|
|
id: 'revenge.timing-log',
|
|
name: 'Startup Timing Log',
|
|
description: "Log Revenge's startup timing into Discord's Startup Timing",
|
|
},
|
|
{
|
|
init() {
|
|
tsInit = performance.now()
|
|
AppStartPerformance.mark('👊', 'Plugins init', tsInit - tsReg)
|
|
},
|
|
start() {
|
|
AppStartPerformance.mark('👊', 'Plugins start', performance.now() - tsInit)
|
|
},
|
|
},
|
|
PluginFlags.Enabled,
|
|
InternalPluginFlags.Internal,
|
|
)
|