1- import { Guild , GuildApplicationCommandManager } from " discord.js" ;
2- import { CommandHandler } from " ../CommandHandler" ;
3- import areSlashCommandsDifferent from " ../utils/areSlashCommandsDifferent" ;
4- import " colors" ;
1+ import { Guild , GuildApplicationCommandManager } from ' discord.js' ;
2+ import { CommandHandler } from ' ../CommandHandler' ;
3+ import areSlashCommandsDifferent from ' ../utils/areSlashCommandsDifferent' ;
4+ import colors from 'colors/safe' ;
55
66export default async function registerCommands ( commandHandler : CommandHandler ) {
77 const client = commandHandler . _data . client ;
88 const devGuildIds = commandHandler . _data . devGuildIds ;
99 const commands = commandHandler . _data . commands ;
1010
11- client . once ( " ready" , async ( ) => {
11+ client . once ( ' ready' , async ( ) => {
1212 const devGuilds : Guild [ ] = [ ] ;
1313
1414 for ( const devGuildId of devGuildIds ) {
1515 const guild = client . guilds . cache . get ( devGuildId ) ;
1616
1717 if ( ! guild ) {
18- console . log ( `⏩ Ignoring: Guild ${ devGuildId } does not exist or client isn't in this guild.` . yellow ) ;
18+ console . log (
19+ colors . yellow ( `⏩ Ignoring: Guild ${ devGuildId } does not exist or client isn't in this guild.` )
20+ ) ;
1921 continue ;
2022 }
2123
@@ -39,10 +41,12 @@ export default async function registerCommands(commandHandler: CommandHandler) {
3941 const targetCommand = appCommands ?. cache . find ( ( cmd ) => cmd . name === command . data . name ) ;
4042
4143 if ( ! targetCommand ) {
42- console . log ( `⏩ Ignoring: Command "${ command . data . name } " is globally marked as deleted.` . yellow ) ;
44+ console . log (
45+ colors . yellow ( `⏩ Ignoring: Command "${ command . data . name } " is globally marked as deleted.` )
46+ ) ;
4347 } else {
4448 targetCommand . delete ( ) . then ( ( ) => {
45- console . log ( `🚮 Deleted command "${ command . data . name } " globally.` . green ) ;
49+ console . log ( colors . green ( `🚮 Deleted command "${ command . data . name } " globally.` ) ) ;
4650 } ) ;
4751 }
4852
@@ -51,13 +55,16 @@ export default async function registerCommands(commandHandler: CommandHandler) {
5155
5256 if ( ! targetCommand ) {
5357 console . log (
54- `⏩ Ignoring: Command "${ command . data . name } " is marked as deleted for ${ guildCommands . guild . name } .`
55- . yellow
58+ colors . yellow (
59+ `⏩ Ignoring: Command "${ command . data . name } " is marked as deleted for ${ guildCommands . guild . name } .`
60+ )
5661 ) ;
5762 } else {
5863 targetCommand . delete ( ) . then ( ( ) => {
5964 console . log (
60- `🚮 Deleted command "${ command . data . name } " in ${ guildCommands . guild . name } .` . green
65+ colors . green (
66+ `🚮 Deleted command "${ command . data . name } " in ${ guildCommands . guild . name } .`
67+ )
6168 ) ;
6269 } ) ;
6370 }
@@ -80,10 +87,10 @@ export default async function registerCommands(commandHandler: CommandHandler) {
8087 appGlobalCommand
8188 . edit ( commandData )
8289 . then ( ( ) => {
83- console . log ( `✅ Edited command "${ commandData . name } " globally.` . green ) ;
90+ console . log ( colors . green ( `✅ Edited command "${ commandData . name } " globally.` ) ) ;
8491 } )
8592 . catch ( ( error ) => {
86- console . log ( `❌ Failed to edit command "${ commandData . name } " globally.` . red ) ;
93+ console . log ( colors . red ( `❌ Failed to edit command "${ commandData . name } " globally.` ) ) ;
8794 console . error ( error ) ;
8895 } ) ;
8996
@@ -103,13 +110,16 @@ export default async function registerCommands(commandHandler: CommandHandler) {
103110 . edit ( commandData )
104111 . then ( ( ) => {
105112 console . log (
106- `✅ Edited command "${ commandData . name } " in ${ guildCommands . guild . name } .` . green
113+ colors . green (
114+ `✅ Edited command "${ commandData . name } " in ${ guildCommands . guild . name } .`
115+ )
107116 ) ;
108117 } )
109118 . catch ( ( error ) => {
110119 console . log (
111- `❌ Failed to edit command "${ commandData . name } " in ${ guildCommands . guild . name } .`
112- . red
120+ colors . red (
121+ `❌ Failed to edit command "${ commandData . name } " in ${ guildCommands . guild . name } .`
122+ )
113123 ) ;
114124 console . error ( error ) ;
115125 } ) ;
@@ -126,8 +136,9 @@ export default async function registerCommands(commandHandler: CommandHandler) {
126136 if ( command . options ?. devOnly ) {
127137 if ( ! devGuilds . length ) {
128138 console . log (
129- `⏩ Ignoring: Cannot register command "${ command . data . name } " as no valid "devGuildIds" were provided.`
130- . yellow
139+ colors . yellow (
140+ `⏩ Ignoring: Cannot register command "${ command . data . name } " as no valid "devGuildIds" were provided.`
141+ )
131142 ) ;
132143 continue ;
133144 }
@@ -139,10 +150,12 @@ export default async function registerCommands(commandHandler: CommandHandler) {
139150 guild ?. commands
140151 . create ( command . data )
141152 . then ( ( ) => {
142- console . log ( `✅ Registered command "${ command . data . name } " in ${ guild . name } .` . green ) ;
153+ console . log ( colors . green ( `✅ Registered command "${ command . data . name } " in ${ guild . name } .` ) ) ;
143154 } )
144155 . catch ( ( error ) => {
145- console . log ( `❌ Failed to register command "${ command . data . name } " in ${ guild . name } .` . red ) ;
156+ console . log (
157+ colors . red ( `❌ Failed to register command "${ command . data . name } " in ${ guild . name } .` )
158+ ) ;
146159 console . error ( error ) ;
147160 } ) ;
148161 }
@@ -155,10 +168,10 @@ export default async function registerCommands(commandHandler: CommandHandler) {
155168 appCommands
156169 ?. create ( command . data )
157170 . then ( ( ) => {
158- console . log ( `✅ Registered command "${ command . data . name } " globally.` . green ) ;
171+ console . log ( colors . green ( `✅ Registered command "${ command . data . name } " globally.` ) ) ;
159172 } )
160173 . catch ( ( error ) => {
161- console . log ( `❌ Failed to register command "${ command . data . name } " globally.` . red ) ;
174+ console . log ( colors . red ( `❌ Failed to register command "${ command . data . name } " globally.` ) ) ;
162175 console . error ( error ) ;
163176 } ) ;
164177 }
0 commit comments