commandkit
Advanced tools
Comparing version 0.1.10-dev.20231229085439 to 0.1.10-dev.20231229094034
@@ -129,3 +129,3 @@ "use strict"; | ||
} else { | ||
throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`)); | ||
throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`)); | ||
} | ||
@@ -154,14 +154,12 @@ } else { | ||
await client.application.commands.set(requestBody).catch((error) => { | ||
console.log( | ||
throw new Error( | ||
colors_default.red( | ||
`\u274C Error ${reloading ? "reloading" : "loading"} global application commands. | ||
`Error ${reloading ? "reloading" : "loading"} global application commands. | ||
` | ||
) | ||
), | ||
error | ||
); | ||
throw new Error(error); | ||
}); | ||
console.log( | ||
colors_default.green( | ||
`\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.` | ||
) | ||
colors_default.green(`${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.`) | ||
); | ||
@@ -174,4 +172,4 @@ } | ||
if (!targetGuild) { | ||
console.log( | ||
`Couldn't ${reloading ? "reloading" : "loading"} commands in guild "${targetGuild}" - guild doesn't exist or client isn't part of the guild.` | ||
process.emitWarning( | ||
`Cannot ${reloading ? "reload" : "load"} commands in guild "${guildId}" - guild doesn't exist or client isn't part of the guild.` | ||
); | ||
@@ -181,13 +179,13 @@ continue; | ||
await targetGuild.commands.set(requestBody).catch((error) => { | ||
console.log( | ||
throw new Error( | ||
colors_default.red( | ||
`\u274C Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}". | ||
`Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}". | ||
` | ||
) | ||
), | ||
error | ||
); | ||
throw new Error(error); | ||
}); | ||
console.log( | ||
colors_default.green( | ||
`\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".` | ||
`${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".` | ||
) | ||
@@ -219,3 +217,3 @@ ); | ||
} else { | ||
throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`)); | ||
throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`)); | ||
} | ||
@@ -249,5 +247,5 @@ } else { | ||
if (!targetCommand) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Command "${command.data.name}" is globally marked as deleted.` | ||
`Ignoring: Command "${command.data.name}" is globally marked as deleted.` | ||
) | ||
@@ -257,8 +255,9 @@ ); | ||
await targetCommand.delete().catch((error) => { | ||
console.log( | ||
colors_default.red(`\u274C Failed to delete command "${command.data.name}" globally.`) | ||
throw new Error( | ||
colors_default.red(`Failed to delete command "${command.data.name}" globally. | ||
`), | ||
error | ||
); | ||
console.error(error); | ||
}); | ||
console.log(colors_default.green(`\u{1F6AE} Deleted command "${command.data.name}" globally.`)); | ||
console.log(colors_default.green(`Deleted command "${command.data.name}" globally.`)); | ||
} | ||
@@ -271,10 +270,9 @@ continue; | ||
await targetCommand.edit(command.data).catch((error) => { | ||
console.log( | ||
colors_default.red( | ||
`\u274C Failed to edit command "${command.data.name}" globally.` | ||
) | ||
throw new Error( | ||
colors_default.red(`Failed to edit command "${command.data.name}" globally. | ||
`), | ||
error | ||
); | ||
console.error(error); | ||
}); | ||
console.log(colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`)); | ||
console.log(colors_default.green(`Edited command "${command.data.name}" globally.`)); | ||
continue; | ||
@@ -286,8 +284,9 @@ } | ||
await appCommandsManager.create(command.data).catch((error) => { | ||
console.log( | ||
colors_default.red(`\u274C Failed to register command "${command.data.name}" globally.`) | ||
throw new Error( | ||
colors_default.red(`Failed to register command "${command.data.name}" globally. | ||
`), | ||
error | ||
); | ||
console.error(error); | ||
}); | ||
console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`)); | ||
console.log(colors_default.green(`Registered command "${command.data.name}" globally.`)); | ||
} | ||
@@ -300,5 +299,5 @@ } | ||
if (!guild) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Guild ${guildId} does not exist or client isn't in this guild.` | ||
`Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.` | ||
) | ||
@@ -321,5 +320,5 @@ ); | ||
if (!targetCommand) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Command "${command.data.name}" is marked as deleted for ${guildCommands.guild.name}.` | ||
`Ignoring: Command "${command.data.name}" is marked as deleted in ${guildCommands.guild.name}.` | ||
) | ||
@@ -329,12 +328,12 @@ ); | ||
await targetCommand.delete().catch((error) => { | ||
console.log( | ||
throw new Error( | ||
colors_default.red( | ||
`\u274C Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
) | ||
`Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
), | ||
error | ||
); | ||
console.error(error); | ||
}); | ||
console.log( | ||
colors_default.green( | ||
`\u{1F6AE} Deleted command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
`Deleted command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
) | ||
@@ -349,12 +348,13 @@ ); | ||
await targetCommand.edit(command.data).catch((error) => { | ||
console.log( | ||
throw new Error( | ||
colors_default.red( | ||
`\u274C Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
) | ||
`Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}. | ||
` | ||
), | ||
error | ||
); | ||
console.error(error); | ||
}); | ||
console.log( | ||
colors_default.green( | ||
`\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
`Edited command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
) | ||
@@ -368,12 +368,13 @@ ); | ||
await guildCommands.create(command.data).catch((error) => { | ||
console.log( | ||
throw new Error( | ||
colors_default.red( | ||
`\u274C Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
) | ||
`Failed to register command "${command.data.name}" in ${guildCommands.guild.name}. | ||
` | ||
), | ||
error | ||
); | ||
console.error(error); | ||
}); | ||
console.log( | ||
colors_default.green( | ||
`\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
`Registered command "${command.data.name}" in ${guildCommands.guild.name}.` | ||
) | ||
@@ -500,5 +501,5 @@ ); | ||
if (devOnlyCommands.length && !this.#data.devGuildIds.length) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
'\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devGuildIds" have not been set.' | ||
'You have commands marked as "devOnly", but "devGuildIds" have not been set.' | ||
) | ||
@@ -508,5 +509,5 @@ ); | ||
if (devOnlyCommands.length && !this.#data.devUserIds.length && !this.#data.devRoleIds.length) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
'\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.' | ||
'You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.' | ||
) | ||
@@ -550,5 +551,5 @@ ); | ||
if (!commandObj.data) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Command ${compactFilePath} does not export "data".` | ||
`Ignoring: Command file ${compactFilePath} does not export "data".` | ||
) | ||
@@ -559,5 +560,5 @@ ); | ||
if (!commandObj.data.name) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Command ${compactFilePath} does not export "data.name".` | ||
`Ignoring: Command file ${compactFilePath} does not export "data.name".` | ||
) | ||
@@ -568,5 +569,5 @@ ); | ||
if (!commandObj.run) { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run".` | ||
`Ignoring: Command file ${commandObj.data.name} does not export "run".` | ||
) | ||
@@ -577,5 +578,5 @@ ); | ||
if (typeof commandObj.run !== "function") { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run" as a function.` | ||
`Ignoring: Command file ${commandObj.data.name} does not export "run" as a function.` | ||
) | ||
@@ -665,3 +666,5 @@ ); | ||
throw new Error( | ||
'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.' | ||
colors_default.red( | ||
'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.' | ||
) | ||
); | ||
@@ -728,5 +731,5 @@ } | ||
if (typeof eventFunction !== "function") { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Event ${compactFilePath} does not export a function.` | ||
`Ignoring: Event file ${compactFilePath} does not export a function.` | ||
) | ||
@@ -760,3 +763,5 @@ ); | ||
throw new Error( | ||
'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.' | ||
colors_default.red( | ||
'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.' | ||
) | ||
); | ||
@@ -801,5 +806,5 @@ } | ||
if (typeof validationFunction !== "function") { | ||
console.log( | ||
process.emitWarning( | ||
colors_default.yellow( | ||
`\u23E9 Ignoring: Validation ${compactFilePath} does not export a function.` | ||
`Ignoring: Validation file ${compactFilePath} does not export a function.` | ||
) | ||
@@ -819,3 +824,5 @@ ); | ||
throw new Error( | ||
'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.' | ||
colors_default.red( | ||
'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.' | ||
) | ||
); | ||
@@ -822,0 +829,0 @@ } |
{ | ||
"name": "commandkit", | ||
"description": "Beginner friendly command & event handler for Discord.js", | ||
"version": "0.1.10-dev.20231229085439", | ||
"version": "0.1.10-dev.20231229094034", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
3026
119305