11import { Guild , GuildApplicationCommandManager } from "discord.js" ;
22import { CommandHandler } from "../CommandHandler" ;
33import areSlashCommandsDifferent from "../utils/areSlashCommandsDifferent" ;
4+ import "colors" ;
45
56export default async function registerCommands ( commandHandler : CommandHandler ) {
67 const client = commandHandler . _data . client ;
@@ -14,7 +15,7 @@ export default async function registerCommands(commandHandler: CommandHandler) {
1415 const guild = client . guilds . cache . get ( devGuildId ) ;
1516
1617 if ( ! guild ) {
17- console . log ( `⏩ Ignoring: Guild ${ devGuildId } does not exist or client isn't in this guild.` ) ;
18+ console . log ( `⏩ Ignoring: Guild ${ devGuildId } does not exist or client isn't in this guild.` . yellow ) ;
1819 continue ;
1920 }
2021
@@ -38,10 +39,10 @@ export default async function registerCommands(commandHandler: CommandHandler) {
3839 const targetCommand = appCommands ?. cache . find ( ( cmd ) => cmd . name === command . data . name ) ;
3940
4041 if ( ! targetCommand ) {
41- console . log ( `⏩ Ignoring: Command "${ command . data . name } " is globally marked as deleted.` ) ;
42+ console . log ( `⏩ Ignoring: Command "${ command . data . name } " is globally marked as deleted.` . yellow ) ;
4243 } else {
4344 targetCommand . delete ( ) . then ( ( ) => {
44- console . log ( `🚮 Deleted command "${ command . data . name } " globally.` ) ;
45+ console . log ( `🚮 Deleted command "${ command . data . name } " globally.` . green ) ;
4546 } ) ;
4647 }
4748
@@ -51,10 +52,13 @@ export default async function registerCommands(commandHandler: CommandHandler) {
5152 if ( ! targetCommand ) {
5253 console . log (
5354 `⏩ Ignoring: Command "${ command . data . name } " is marked as deleted for ${ guildCommands . guild . name } .`
55+ . yellow
5456 ) ;
5557 } else {
5658 targetCommand . delete ( ) . then ( ( ) => {
57- console . log ( `🚮 Deleted command "${ command . data . name } " in ${ guildCommands . guild . name } .` ) ;
59+ console . log (
60+ `🚮 Deleted command "${ command . data . name } " in ${ guildCommands . guild . name } .` . green
61+ ) ;
5862 } ) ;
5963 }
6064 }
@@ -76,10 +80,10 @@ export default async function registerCommands(commandHandler: CommandHandler) {
7680 appGlobalCommand
7781 . edit ( commandData )
7882 . then ( ( ) => {
79- console . log ( `✅ Edited command "${ commandData . name } " globally.` ) ;
83+ console . log ( `✅ Edited command "${ commandData . name } " globally.` . green ) ;
8084 } )
8185 . catch ( ( error ) => {
82- console . log ( `❌ Failed to edit command "${ commandData . name } " globally.` ) ;
86+ console . log ( `❌ Failed to edit command "${ commandData . name } " globally.` . red ) ;
8387 console . error ( error ) ;
8488 } ) ;
8589
@@ -98,11 +102,14 @@ export default async function registerCommands(commandHandler: CommandHandler) {
98102 appGuildCommand
99103 . edit ( commandData )
100104 . then ( ( ) => {
101- console . log ( `✅ Edited command "${ commandData . name } " in ${ guildCommands . guild . name } .` ) ;
105+ console . log (
106+ `✅ Edited command "${ commandData . name } " in ${ guildCommands . guild . name } .` . green
107+ ) ;
102108 } )
103109 . catch ( ( error ) => {
104110 console . log (
105111 `❌ Failed to edit command "${ commandData . name } " in ${ guildCommands . guild . name } .`
112+ . red
106113 ) ;
107114 console . error ( error ) ;
108115 } ) ;
@@ -120,6 +127,7 @@ export default async function registerCommands(commandHandler: CommandHandler) {
120127 if ( ! devGuilds . length ) {
121128 console . log (
122129 `⏩ Ignoring: Cannot register command "${ command . data . name } " as no valid "devGuildIds" were provided.`
130+ . yellow
123131 ) ;
124132 continue ;
125133 }
@@ -131,10 +139,10 @@ export default async function registerCommands(commandHandler: CommandHandler) {
131139 guild ?. commands
132140 . create ( command . data )
133141 . then ( ( ) => {
134- console . log ( `✅ Registered command "${ command . data . name } " in ${ guild . name } .` ) ;
142+ console . log ( `✅ Registered command "${ command . data . name } " in ${ guild . name } .` . green ) ;
135143 } )
136144 . catch ( ( error ) => {
137- console . log ( `❌ Failed to register command "${ command . data . name } " in ${ guild . name } .` ) ;
145+ console . log ( `❌ Failed to register command "${ command . data . name } " in ${ guild . name } .` . red ) ;
138146 console . error ( error ) ;
139147 } ) ;
140148 }
@@ -147,10 +155,10 @@ export default async function registerCommands(commandHandler: CommandHandler) {
147155 appCommands
148156 ?. create ( command . data )
149157 . then ( ( ) => {
150- console . log ( `✅ Registered command "${ command . data . name } " globally.` ) ;
158+ console . log ( `✅ Registered command "${ command . data . name } " globally.` . green ) ;
151159 } )
152160 . catch ( ( error ) => {
153- console . log ( `❌ Failed to register command "${ command . data . name } " globally.` ) ;
161+ console . log ( `❌ Failed to register command "${ command . data . name } " globally.` . red ) ;
154162 console . error ( error ) ;
155163 } ) ;
156164 }
0 commit comments