diff --git a/functions.js b/functions.js index 863bd28..05ef8cd 100644 --- a/functions.js +++ b/functions.js @@ -44,7 +44,7 @@ function stringify(object){ try { return JSON.stringify(object) } catch (err) { - return "" + return ` ${object}` } } diff --git a/index.js b/index.js index 0f02c55..6e90243 100644 --- a/index.js +++ b/index.js @@ -206,8 +206,8 @@ function loadModules(){ if(typeof manifest?.files != "object") errors.push(`Impossible de charger le module ${chalk.yellow(module)} : la valeur ${chalk.yellow("files")} n'est pas de type ${chalk.yellow("array")}.`) // Si un module avec le même nom de packet existe déjà - if(allModules.find(moduleA => moduleA.packageName == manifest.packageName)) errors.push(`Impossible de charger le module ${chalk.yellow(module)} : un module avec le même nom de packet existe déjà.`) - if(allModules.find(moduleA => moduleA.packageName == module)) errors.push(`Impossible de charger le module ${chalk.yellow(module)} : un module avec le même nom de packet existe déjà.`) + if(allModules.find(moduleA => moduleA?.packageName == manifest?.packageName)) errors.push(`Impossible de charger le module ${chalk.yellow(module)} : un module avec le même nom de packet existe déjà.`) + if(allModules.find(moduleA => moduleA?.packageName == module)) errors.push(`Impossible de charger le module ${chalk.yellow(module)} : un module avec le même nom de packet existe déjà.`) // Vérifier que les librairies nécessaires existent if(manifest?.dependencies) for(var dependencie of manifest.dependencies){ @@ -536,10 +536,9 @@ client.on("interactionCreate", async interaction => { bacheroFunctions.showLog("warn", `${interaction.user.discriminator == "0" ? interaction.user.username : interaction.user.tag} a exécuté la commande slash ${chalk.yellow(interaction.commandName)} qui a fini en une erreur :`, "user-slashcommand-error") bacheroFunctions.showLog("warn", error.stack || error, "user-slashcommand-error", true, true) try { - interaction.reply({ embeds: [createErrorEmbed("Une erreur est survenue", `Un problème est survenu lors de l'exécution de la commande :\n\`\`\`\n${error?.toString()?.replace(/`/g, " `") || error}\n\`\`\``, "dangerEmbedColor", true)], ephemeral: false }).catch(err => {}) - } catch (error){ - await interaction.editReply({ embeds: [createErrorEmbed("Une erreur est survenue", `Un problème est survenu lors de l'exécution de la commande :\n\`\`\`\n${error?.toString()?.replace(/`/g, " `") || error}\n\`\`\``, "dangerEmbedColor", true)], ephemeral: false }).catch(err => {}) - } + if(interaction.replied || interaction.deferred) await interaction.editReply({ embeds: [createErrorEmbed("Une erreur est survenue", `Un problème est survenu lors de l'exécution de la commande :\n\`\`\`\n${error?.toString()?.replace(/`/g, " `") || error}\n\`\`\``, "dangerEmbedColor", true)], ephemeral: false }).catch(err => {}) + else interaction.reply({ embeds: [createErrorEmbed("Une erreur est survenue", `Un problème est survenu lors de l'exécution de la commande :\n\`\`\`\n${error?.toString()?.replace(/`/g, " `") || error}\n\`\`\``, "dangerEmbedColor", true)], ephemeral: false }).catch(err => {}) + } catch (error){} } // Mettre à jour les statistiques diff --git a/modules/bachero.module.analytics/analytics.js b/modules/bachero.module.analytics/analytics.js index f74b433..5a05215 100644 --- a/modules/bachero.module.analytics/analytics.js +++ b/modules/bachero.module.analytics/analytics.js @@ -98,7 +98,7 @@ module.exports = { if(!disableTextCommand) lines.push(`**Utilisations par méthodes**\n${Object.entries(command[1].method).map(method => { return `ㅤ • ${method[0].replace("slash", "Commande slash").replace("text", "Commande texte")} : ${method[1]}` }).join("\n")}\n`) lines.push(`**Utilisations par périodes**\n${Object.entries(command[1].periods).map(period => { return `ㅤ • ${period[0].replace("morning", "En matinée").replace("afternoon", "En après-midi").replace("evening", "En soirée").replace("night", "Pendant la nuit")} : ${period[1]}` }).join("\n")}\n`) lines.push(`**Utilisations par jours**\n${Object.entries(command[1].weekday).map(day => { return `ㅤ • ${day[0].replace("monday", "Lundi").replace("tuesday", "Mardi").replace("wednesday", "Mercredi").replace("thursday", "Jeudi").replace("friday", "Vendredi").replace("saturday", "Samedi").replace("sunday", "Dimanche")} : ${day[1]}` }).join("\n")}\n`) - if(Object.entries(command[1].subCommands).length) lines.push(`**Utilisation des sous commandes**\n${Object.entries(command[1].subCommands).map(subCommand => { return `ㅤ • ${subCommand[0]} : ${subCommand[1]}` }).join("\n")}\n`) + if(command[1].subCommands && Object.entries(command[1].subCommands).length) lines.push(`**Utilisation des sous commandes**\n${Object.entries(command[1].subCommands).map(subCommand => { return `ㅤ • ${subCommand[0]} : ${subCommand[1]}` }).join("\n")}\n`) lines.push(`**Utilisations totales :** ${command[1].totalCount}`) if(command[1].lastExecution) lines.push(`**Dernière exécution :** \n`)