best configuration for embed , blrank and alias et ajout du system des blword ( badword)

This commit is contained in:
VALOU3336
2024-03-03 19:18:19 +01:00
parent b3fd7d79a8
commit 52da255455
7 changed files with 202 additions and 34 deletions
+18 -2
View File
@@ -28,6 +28,11 @@ module.exports = {
if (!command) {
return message.reply(`La commande ${commandName} n'existe pas.`);
}
const aliasCheck = isAliasUnique(client, newAlias);
if (!aliasCheck.isUnique) {
return message.reply(`Cet alias est déjà utilisé par la commande \`${aliasCheck.conflictCommand}\`.`);
}
let data = await new Promise((resolve, reject) => {
db.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => {
@@ -45,7 +50,7 @@ module.exports = {
for (const cmd in data.alias) {
if (data.alias[cmd][newAlias]) {
return message.reply('Cet alias est déjà utilisé pour une autre commande.');
return message.reply(`Cet alias est déjà utilisé par la commande \`${cmd}\`.`);
}
}
@@ -118,4 +123,15 @@ module.exports = {
return message.reply('Sous-commande invalide. Veuillez utiliser add, remove, ou list.');
}
},
};
};
function isAliasUnique(client, newAlias) {
for (const command of client.commands.values()) {
if (command.name === newAlias) {
return { isUnique: false, conflictCommand: command.name };
}
if (command.aliases && command.aliases.includes(newAlias)) {
return { isUnique: false, conflictCommand: command.name };
}
}
return { isUnique: true };
}