import { Command } from "../base/Command" ; import { TundraBot } from "../base/TundraBot" ; export default class Deps { static testing = false ; private static deps : any [ ] = [ ] ; static build ( ... types ) { if ( this . testing ) return ; for ( const Type of types ) { try { this . deps . push ( new Type ( ) ) ; } catch { } } } static removeCommand ( commandName ) { try { this . deps = this . deps . filter ( ( dep ) => ! ( dep instanceof Command && dep . name === commandName ) ) ; return true ; } catch { return false ; } } static buildDB ( client , ... types ) { this . buildWithClient ( client , ... types ) ; } static buildWithClient ( client , ... types ) { if ( this . testing ) return ; for ( const Type of types ) { try { this . deps . push ( new Type ( client ) ) ; } catch { } } } static get < T > ( type ) { const service = this . deps . find ( t => t instanceof type ) ; return service ; } private static add < T > ( instance ) { this . deps . push ( instance ) ; return instance ; } }