Advertisement
padildil

cmdCustom

Nov 15th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 2.47 KB | Source Code | 0 0
  1. case 'addcmd': {
  2.         if (!isCreator && !isGroupAdmins) return reply("Hanya admin atau creator yang dapat menggunakan perintah ini!");
  3.         if (!args[0] || !args[1]) return reply("Format salah! Gunakan: addcmd <command> <response>");
  4.         const cmdName = args[0].startsWith('!') ? args[0]: `!${args[0]}`;
  5.         const cmdResponse = args.slice(1).join(' ');
  6.         if (customCommands.commands[cmdName]) {
  7.           return reply(`Perintah "${cmdName}" sudah ada. Gunakan *editcmd* untuk mengeditnya.`);
  8.         }
  9.         customCommands.commands[cmdName] = cmdResponse;
  10.         fs.writeFileSync('./database/customCommands.json', JSON.stringify(customCommands, null, 2));
  11.         reply(`Perintah "${cmdName}" berhasil ditambahkan dengan respons: ${cmdResponse}`);
  12.       }
  13.         break;
  14.       case 'editcmd': {
  15.         if (!isCreator && !isGroupAdmins) return reply("Hanya admin atau creator yang dapat menggunakan perintah ini!");
  16.         if (!args[0] || !args[1]) return reply("Format salah! Gunakan: editcmd <command> <new response>");
  17.         const cmdName = args[0].startsWith('!') ? args[0]: `!${args[0]}`;
  18.         if (!customCommands.commands[cmdName]) {
  19.           return reply(`Perintah "${cmdName}" tidak ditemukan. Gunakan *addcmd* untuk membuatnya.`);
  20.         }
  21.         const newResponse = args.slice(1).join(' ');
  22.         customCommands.commands[cmdName] = newResponse;
  23.         fs.writeFileSync('./database/customCommands.json', JSON.stringify(customCommands, null, 2));
  24.         reply(`Perintah "${cmdName}" berhasil diperbarui dengan respons baru: ${newResponse}`);
  25.       }
  26.         break;
  27.       case 'delcmd': {
  28.         if (!isCreator && !isGroupAdmins) return reply("Hanya admin atau creator yang dapat menggunakan perintah ini!");
  29.         if (!args[0]) return reply("Format salah! Gunakan: delcmd <command>");
  30.         const cmdName = args[0].startsWith('!') ? args[0]: `!${args[0]}`;
  31.         if (!customCommands.commands[cmdName]) {
  32.           return reply(`Perintah "${cmdName}" tidak ditemukan.`);
  33.         }
  34.         delete customCommands.commands[cmdName];
  35.         fs.writeFileSync('./database/customCommands.json', JSON.stringify(customCommands, null, 2));
  36.         reply(`Perintah "${cmdName}" berhasil dihapus.`);
  37.       }
  38.         break;
  39.       case 'listcmd': {
  40.         const cmdList = Object.keys(customCommands.commands).map(cmd => `• ${cmd}`).join('\n');
  41.         reply(`Daftar Custom Commands:\n${cmdList || "Belum ada custom command."}`);
  42.       }
  43.         break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement