11import { Client , REST , Routes , Events } from 'discord.js'
2- import type { Harmony , HarmonyCommand , HarmonyEvent } from './types'
2+ import type { Harmonix , HarmonixCommand , HarmonixEvent } from './types'
33import 'dotenv/config'
44import { toJSON } from './commands'
55
6- export const initCient = ( harmonyOptions : Harmony [ 'options' ] ) => {
7- const client = new Client ( { intents : harmonyOptions . intents } )
6+ export const initCient = ( harmonixOptions : Harmonix [ 'options' ] ) => {
7+ const client = new Client ( { intents : harmonixOptions . intents } )
88
9- client . login ( process . env . HARMONY_CLIENT_TOKEN )
9+ client . login ( process . env . HARMONIX_CLIENT_TOKEN )
1010
1111 return client
1212}
1313
1414export const registerCommands = (
15- harmony : Harmony ,
16- commands : HarmonyCommand < false > [ ]
15+ harmonix : Harmonix ,
16+ commands : HarmonixCommand < false > [ ]
1717) => {
18- harmony . client ?. on ( Events . MessageCreate , ( message ) => {
18+ harmonix . client ?. on ( Events . MessageCreate , ( message ) => {
1919 if ( message . author . bot ) return
20- const prefix = harmony . options . defaultPrefix
20+ const prefix = harmonix . options . defaultPrefix
2121 const args = message . content . slice ( prefix . length ) . trim ( ) . split ( / + / )
2222 const command = args . shift ( ) ?. toLowerCase ( )
2323
@@ -28,43 +28,43 @@ export const registerCommands = (
2828 cmd ?. options . args ?. map ( ( arg , i ) => [ arg . name , args [ i ] ] ) || [ ]
2929 )
3030 if ( ! cmd || cmd . options . slash ) return
31- cmd . execute ( harmony . client ! , message , { slash : false , params : params } )
31+ cmd . execute ( harmonix . client ! , message , { slash : false , params : params } )
3232 } )
3333}
3434
3535export const registerSlashCommands = async (
36- harmony : Harmony ,
37- commands : HarmonyCommand < true > [ ]
36+ harmonix : Harmonix ,
37+ commands : HarmonixCommand < true > [ ]
3838) => {
3939 if ( commands . length === 0 ) return
40- const rest = new REST ( ) . setToken ( process . env . HARMONY_CLIENT_TOKEN || '' )
40+ const rest = new REST ( ) . setToken ( process . env . HARMONIX_CLIENT_TOKEN || '' )
4141
4242 await rest . put (
4343 Routes . applicationCommands (
44- harmony . options . clientId || process . env . HARMONY_CLIENT_ID || ''
44+ harmonix . options . clientId || process . env . HARMONIX_CLIENT_ID || ''
4545 ) ,
4646 { body : commands . map ( ( cmd ) => toJSON ( cmd ) ) }
4747 )
48- harmony . client ?. on ( 'interactionCreate' , ( interaction ) => {
48+ harmonix . client ?. on ( 'interactionCreate' , ( interaction ) => {
4949 if ( ! interaction . isChatInputCommand ( ) ) return
5050 const cmd = commands . find (
5151 ( cmd ) => cmd . options . name === interaction . commandName
5252 )
5353
5454 if ( ! cmd || ! cmd . options . slash ) return
55- cmd . execute ( harmony . client ! , interaction , {
55+ cmd . execute ( harmonix . client ! , interaction , {
5656 slash : true ,
5757 params : interaction . options
5858 } )
5959 } )
6060}
6161
62- export const registerEvents = ( harmony : Harmony , events : HarmonyEvent [ ] ) => {
62+ export const registerEvents = ( harmonix : Harmonix , events : HarmonixEvent [ ] ) => {
6363 for ( const event of events ) {
6464 if ( event . options . once ) {
65- harmony . client ?. once ( event . options . name ! , event . callback )
65+ harmonix . client ?. once ( event . options . name ! , event . callback )
6666 } else {
67- harmony . client ?. on ( event . options . name ! , event . callback )
67+ harmonix . client ?. on ( event . options . name ! , event . callback )
6868 }
6969 }
7070}
0 commit comments