@@ -6,6 +6,7 @@ import { colors } from 'consola/utils'
66import { watch } from 'chokidar'
77import { resolve } from 'pathe'
88import { debounce } from 'perfect-debounce'
9+ import type { Stats } from 'node:fs'
910import { loadOptions } from './options'
1011import {
1112 scanButtons ,
@@ -46,7 +47,6 @@ import {
4647} from './resolve'
4748import type { Harmonix , HarmonixConfig , HarmonixOptions } from './types'
4849import { version } from '../package.json'
49- import { Stats } from 'fs'
5050
5151export const ctx = getContext < Harmonix > ( 'harmonix' )
5252
@@ -73,12 +73,38 @@ export const createHarmonix = async (
7373 preconditions : new Collection ( )
7474 }
7575
76+ consola . log ( colors . blue ( `Harmonix ${ colors . bold ( version ) } \n` ) )
77+ await loadHarmonix ( harmonix , config , opts )
78+
79+ return harmonix
80+ }
81+
82+ export const createDevHarmonix = async (
83+ config : HarmonixConfig = { } ,
84+ opts : LoadConfigOptions = { }
85+ ) => {
86+ if ( ! process . env . DISCORD_CLIENT_TOKEN ) {
87+ createError (
88+ 'Client token is required. Please provide it in the environment variable DISCORD_CLIENT_TOKEN.'
89+ )
90+ }
91+ const options = await loadOptions ( config , opts )
92+ const harmonix : Harmonix = {
93+ options : options as HarmonixOptions ,
94+ events : new Collection ( ) ,
95+ commands : new Collection ( ) ,
96+ contextMenus : new Collection ( ) ,
97+ buttons : new Collection ( ) ,
98+ modals : new Collection ( ) ,
99+ selectMenus : new Collection ( ) ,
100+ preconditions : new Collection ( )
101+ }
102+
76103 consola . log ( colors . blue ( `Harmonix ${ colors . bold ( version ) } \n` ) )
77104 const watcher = watch ( harmonix . options . scanDirs , {
78105 ignored : harmonix . options . ignore ,
79106 ignoreInitial : true
80107 } )
81-
82108 const reload = debounce (
83109 async ( event : string , path : string , stats : Stats | undefined ) => {
84110 if ( stats ?. size === 0 ) return
0 commit comments