levix-bot 4.0.4 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/package.json +1 -1
  2. package/public/dashboard/assets/index-4AuqfnH5.js +431 -0
  3. package/public/dashboard/assets/index-LvfJ8ybs.css +2 -0
  4. package/public/dashboard/index.html +2 -2
  5. package/scheduler.cjs +25 -1
  6. package/src/commands/autoschedule.cjs +40 -10
  7. package/src/commands/blacklist.cjs +35 -10
  8. package/src/commands/block.cjs +18 -5
  9. package/src/commands/calc.cjs +90 -24
  10. package/src/commands/debt.cjs +59 -33
  11. package/src/commands/deleteschedule.cjs +21 -5
  12. package/src/commands/digit.cjs +34 -8
  13. package/src/commands/gemini.cjs +235 -108
  14. package/src/commands/group/add.cjs +46 -13
  15. package/src/commands/group/all.cjs +15 -5
  16. package/src/commands/group/antiSpam.cjs +11 -4
  17. package/src/commands/group/antilink.cjs +39 -19
  18. package/src/commands/group/approveall.cjs +22 -7
  19. package/src/commands/group/clearwarns.cjs +18 -5
  20. package/src/commands/group/deletenote.cjs +18 -5
  21. package/src/commands/group/demote.cjs +25 -7
  22. package/src/commands/group/kick.cjs +28 -12
  23. package/src/commands/group/media.cjs +34 -13
  24. package/src/commands/group/members.cjs +21 -6
  25. package/src/commands/group/note.cjs +14 -4
  26. package/src/commands/group/promote.cjs +22 -6
  27. package/src/commands/group/removeall.cjs +13 -3
  28. package/src/commands/group/rules.cjs +20 -5
  29. package/src/commands/group/save.cjs +20 -5
  30. package/src/commands/group/setname.cjs +19 -6
  31. package/src/commands/group/setpp.cjs +21 -6
  32. package/src/commands/group/setrules.cjs +17 -5
  33. package/src/commands/group/setwarn.cjs +23 -7
  34. package/src/commands/group/tagadmins.cjs +16 -6
  35. package/src/commands/group/warn.cjs +35 -15
  36. package/src/commands/group/warns.cjs +33 -13
  37. package/src/commands/group/welcome.cjs +34 -16
  38. package/src/commands/group.cjs +96 -70
  39. package/src/commands/help.cjs +270 -129
  40. package/src/commands/lang.cjs +46 -13
  41. package/src/commands/listschedules.cjs +28 -11
  42. package/src/commands/loop.cjs +43 -9
  43. package/src/commands/memory.cjs +90 -30
  44. package/src/commands/mod.cjs +72 -28
  45. package/src/commands/notes.cjs +15 -5
  46. package/src/commands/perm.cjs +52 -20
  47. package/src/commands/ping.cjs +15 -3
  48. package/src/commands/poll.cjs +71 -24
  49. package/src/commands/prayer.cjs +28 -12
  50. package/src/commands/qr.cjs +20 -5
  51. package/src/commands/rand.cjs +54 -12
  52. package/src/commands/restart.cjs +13 -3
  53. package/src/commands/schedule.cjs +32 -9
  54. package/src/commands/score.cjs +26 -10
  55. package/src/commands/setprefix.cjs +27 -5
  56. package/src/commands/shortlink.cjs +36 -10
  57. package/src/commands/shutdown.cjs +13 -3
  58. package/src/commands/status.cjs +32 -11
  59. package/src/commands/sticker.cjs +34 -7
  60. package/src/commands/stt.cjs +159 -107
  61. package/src/commands/todo.cjs +31 -9
  62. package/src/commands/tts.cjs +61 -36
  63. package/src/commands/unblock.cjs +17 -4
  64. package/src/commands/weather.cjs +55 -17
  65. package/src/config/baileys.config.js +5 -1
  66. package/src/config/settings.cjs +11 -3
  67. package/src/core/connection.js +21 -2
  68. package/src/core/socket.js +31 -7
  69. package/src/db/store.cjs +24 -0
  70. package/src/handlers/command.handler.js +55 -13
  71. package/src/handlers/group.handler.js +5 -1
  72. package/src/handlers/message.handler.js +9 -0
  73. package/src/middleware/antispam.middleware.js +13 -3
  74. package/src/middleware/blacklist.middleware.js +4 -1
  75. package/src/middleware/permissions.middleware.js +38 -51
  76. package/src/routes/dashboard.api.esm.js +91 -10
  77. package/src/services/aiAgent.cjs +51 -41
  78. package/src/services/aiProviders.cjs +46 -19
  79. package/src/services/aiRouter.cjs +11 -3
  80. package/src/services/aiToolAuth.cjs +114 -0
  81. package/src/services/aiTools.cjs +492 -56
  82. package/src/services/modelRegistry.cjs +20 -5
  83. package/src/utils/commandDocs.cjs +58 -0
  84. package/src/utils/geminiMedia.cjs +99 -0
  85. package/src/utils/groupMetadataCache.cjs +83 -0
  86. package/src/utils/i18n.cjs +113 -0
  87. package/src/utils/markdownParser.cjs +4 -2
  88. package/src/utils/memory.cjs +37 -21
  89. package/src/utils/permissionLevel.cjs +83 -0
  90. package/src/utils/providerUrl.cjs +29 -2
  91. package/src/utils/sendBotMessage.cjs +7 -3
  92. package/src/utils/sendBotMessage.esm.js +27 -3
  93. package/src/utils/statusMessage.cjs +11 -4
  94. package/src/utils/storage-hub.cjs +21 -0
  95. package/public/dashboard/assets/index-BnJbz8iW.css +0 -2
  96. package/public/dashboard/assets/index-Dn8ZyzsW.js +0 -426
@@ -3,14 +3,22 @@ const { getGroupSettings, saveGroupSettings } = require("../../utils/storage.cjs
3
3
  const logger = require("../../utils/logger.cjs");
4
4
  const { isOwnerJidSync, isAdminInGroupSync } = require("../../utils/permissions.cjs");
5
5
  const { mediaType } = require("../../utils/messageContent.cjs");
6
+ const { resolveGroupMetadata } = require("../../utils/groupMetadataCache.cjs");
7
+ const { tr } = require("../../utils/i18n.cjs");
6
8
 
7
9
  const VALID_TYPES = ["image", "video", "sticker", "audio"];
8
10
 
9
11
  // --- The Main Command Logic ---
10
12
  const command = {
11
13
  name: "media",
12
- description: "Controls which message types are allowed in the group.",
13
- usage: "media [status]\nmedia <on|off>\nmedia <block|unblock> <image|video|sticker|audio>",
14
+ description: {
15
+ en: "Controls which message types are allowed in the group.",
16
+ ar: "يتحكم في أنواع الرسائل المسموح بها في المجموعة.",
17
+ },
18
+ usage: {
19
+ en: "media [status]\nmedia <on|off>\nmedia <block|unblock> <image|video|sticker|audio>",
20
+ ar: "media [status]\nmedia <on|off>\nmedia <block|unblock> <image|video|sticker|audio>",
21
+ },
14
22
  chat: "group",
15
23
  userAdminRequired: true,
16
24
 
@@ -28,26 +36,29 @@ const command = {
28
36
  case "on":
29
37
  mediaConfig.enabled = true;
30
38
  await sock.sendMessage(groupId, {
31
- text: "✅ تم تفعيل نظام مراقبة الوسائط.",
39
+ text: tr("✅ Media control is on.", "✅ تم تفعيل نظام مراقبة الوسائط."),
32
40
  });
33
41
  break;
34
42
  case "off":
35
43
  mediaConfig.enabled = false;
36
44
  await sock.sendMessage(groupId, {
37
- text: "☑️ تم تعطيل نظام مراقبة الوسائط.",
45
+ text: tr("☑️ Media control is off.", "☑️ تم تعطيل نظام مراقبة الوسائط."),
38
46
  });
39
47
  break;
40
48
  case "block": {
41
49
  const typeToBlock = args[1] ? args[1].toLowerCase() : "";
42
50
  if (!VALID_TYPES.includes(typeToBlock))
43
51
  return await sock.sendMessage(groupId, {
44
- text: `نوع غير صالح. الأنواع المتاحة: ${VALID_TYPES.join(", ")}`,
52
+ text: tr(
53
+ `Invalid type. Available types: ${VALID_TYPES.join(", ")}`,
54
+ `نوع غير صالح. الأنواع المتاحة: ${VALID_TYPES.join(", ")}`,
55
+ ),
45
56
  });
46
57
  if (!mediaConfig.blocked_types.includes(typeToBlock)) {
47
58
  mediaConfig.blocked_types.push(typeToBlock);
48
59
  }
49
60
  await sock.sendMessage(groupId, {
50
- text: `✅ تم إضافة '${typeToBlock}' للأنواع الممنوعة.`,
61
+ text: tr(`✅ '${typeToBlock}' is now blocked.`, `✅ تم إضافة '${typeToBlock}' للأنواع الممنوعة.`),
51
62
  });
52
63
  break;
53
64
  }
@@ -55,19 +66,25 @@ const command = {
55
66
  const typeToUnblock = args[1] ? args[1].toLowerCase() : "";
56
67
  if (!typeToUnblock)
57
68
  return await sock.sendMessage(groupId, {
58
- text: "يرجى تحديد نوع لإلغاء حظره.",
69
+ text: tr("Say which type to unblock.", "يرجى تحديد نوع لإلغاء حظره."),
59
70
  });
60
71
  mediaConfig.blocked_types = mediaConfig.blocked_types.filter((t) => t !== typeToUnblock);
61
72
  await sock.sendMessage(groupId, {
62
- text: `☑️ تم إزالة '${typeToUnblock}' من الأنواع الممنوعة.`,
73
+ text: tr(
74
+ `☑️ '${typeToUnblock}' is no longer blocked.`,
75
+ `☑️ تم إزالة '${typeToUnblock}' من الأنواع الممنوعة.`,
76
+ ),
63
77
  });
64
78
  break;
65
79
  }
66
80
  default: {
67
81
  // 'status'
68
- let statusReply = `*حالة نظام مراقبة الوسائط:*\n\n`;
69
- statusReply += `الحالة: ${mediaConfig.enabled ? "مفعل ✅" : "معطل ☑️"}\n`;
70
- statusReply += `الأنواع الممنوعة: ${mediaConfig.blocked_types.join(", ") || "لا يوجد"}`;
82
+ const state = mediaConfig.enabled ? tr("on ✅", "مفعل ✅") : tr("off ☑️", "معطل ☑️");
83
+ const blocked = mediaConfig.blocked_types.join(", ") || tr("none", "لا يوجد");
84
+ const statusReply = tr(
85
+ `*Media control:*\n\nState: ${state}\nBlocked types: ${blocked}`,
86
+ `*حالة نظام مراقبة الوسائط:*\n\nالحالة: ${state}\nالأنواع الممنوعة: ${blocked}`,
87
+ );
71
88
  await sock.sendMessage(groupId, { text: statusReply });
72
89
  }
73
90
  }
@@ -88,7 +105,8 @@ async function handleMediaControl(sock, msg, _legacyConfig, _normalizeJid) {
88
105
 
89
106
  const senderId = msg.key.participant || msg.key.remoteJid;
90
107
 
91
- const groupMetadata = await sock.groupMetadata(groupId);
108
+ // Cache-first: this runs on every group message while media control is on.
109
+ const groupMetadata = await resolveGroupMetadata(sock, groupId);
92
110
  const senderIds = [senderId, msg.key.participantAlt, msg.key.participantPn].filter(Boolean);
93
111
  const isOwner = msg.key.fromMe || senderIds.some(isOwnerJidSync);
94
112
  const isSenderAdmin = senderIds.some((id) => isAdminInGroupSync(groupMetadata, id));
@@ -101,7 +119,10 @@ async function handleMediaControl(sock, msg, _legacyConfig, _normalizeJid) {
101
119
  logger.info(`[Media Control] Deleting ${messageType} from ${senderId} in ${groupId}.`);
102
120
  await sock.sendMessage(groupId, { delete: msg.key });
103
121
  await sock.sendMessage(groupId, {
104
- text: `يا @${senderId.split("@")[0]}، إرسال *${messageType}* ممنوع هنا.`,
122
+ text: tr(
123
+ `@${senderId.split("@")[0]}, *${messageType}* isn't allowed here.`,
124
+ `يا @${senderId.split("@")[0]}، إرسال *${messageType}* ممنوع هنا.`,
125
+ ),
105
126
  mentions: [senderId],
106
127
  });
107
128
  return true; // Action was taken
@@ -1,10 +1,17 @@
1
1
  // file: /commands/members.js
2
2
  const logger = require("../../utils/logger.cjs");
3
+ const { tr } = require("../../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "members",
6
- description: "Lists all members in the group with their numbers.",
7
- usage: "members",
7
+ description: {
8
+ en: "Lists every member of the group with their number.",
9
+ ar: "يعرض كل أعضاء المجموعة مع أرقامهم.",
10
+ },
11
+ usage: {
12
+ en: "members",
13
+ ar: "members",
14
+ },
8
15
  chat: "group", // This command only works in groups
9
16
 
10
17
  async execute(sock, msg) {
@@ -13,7 +20,9 @@ module.exports = {
13
20
  const groupId = msg.key.remoteJid;
14
21
 
15
22
  // Send a temporary message to let the user know we're working on it
16
- await sock.sendMessage(groupId, { text: "جاري جلب قائمة الأعضاء..." });
23
+ await sock.sendMessage(groupId, {
24
+ text: tr("Fetching the member list...", "جاري جلب قائمة الأعضاء..."),
25
+ });
17
26
 
18
27
  // Fetch the group's metadata
19
28
  const metadata = await sock.groupMetadata(groupId);
@@ -22,7 +31,10 @@ module.exports = {
22
31
  // --- Building the reply message ---
23
32
 
24
33
  // Start with a header
25
- let replyText = `*قائمة أعضاء الجروب:*\n*العدد الإجمالي: ${members.length}*\n\n`;
34
+ let replyText = tr(
35
+ `*Group members:*\n*Total: ${members.length}*\n\n`,
36
+ `*قائمة أعضاء الجروب:*\n*العدد الإجمالي: ${members.length}*\n\n`,
37
+ );
26
38
 
27
39
  // Create an array of JIDs for the mentions property
28
40
  const mentions = [];
@@ -37,7 +49,7 @@ module.exports = {
37
49
 
38
50
  // Add the formatted line to our reply text
39
51
  // Using @ will create a "mention link" in the WhatsApp message
40
- replyText += `${index + 1}. @${phone}${isAdmin ? " 👑 *مشرف*" : ""}\n`;
52
+ replyText += `${index + 1}. @${phone}${isAdmin ? tr(" 👑 *admin*", " 👑 *مشرف*") : ""}\n`;
41
53
 
42
54
  // Add the member's JID to the mentions array
43
55
  mentions.push(member.id);
@@ -51,7 +63,10 @@ module.exports = {
51
63
  } catch (error) {
52
64
  logger.error(error, "[Error] in !members command:");
53
65
  await sock.sendMessage(msg.key.remoteJid, {
54
- text: "حدث خطأ أثناء جلب قائمة الأعضاء.",
66
+ text: tr(
67
+ "Something went wrong while fetching the member list.",
68
+ "حدث خطأ أثناء جلب قائمة الأعضاء.",
69
+ ),
55
70
  });
56
71
  }
57
72
  },
@@ -1,10 +1,17 @@
1
1
  // file: /commands/note.js
2
2
  const { getAllNotes, getNote } = require("../../utils/storage.cjs");
3
+ const { tr } = require("../../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "note",
6
- description: "Retrieves a saved note.",
7
- usage: "note #الكلمة-المفتاحية",
7
+ description: {
8
+ en: "Shows a saved note.",
9
+ ar: "يعرض ملاحظة محفوظة.",
10
+ },
11
+ usage: {
12
+ en: "note #keyword",
13
+ ar: "note #الكلمة-المفتاحية",
14
+ },
8
15
  chat: "all",
9
16
 
10
17
  async execute(sock, msg, args) {
@@ -13,7 +20,7 @@ module.exports = {
13
20
 
14
21
  if (!keywordArg || !keywordArg.startsWith("#")) {
15
22
  return await sock.sendMessage(groupId, {
16
- text: "صيغة غير صحيحة. استخدم: `!note #keyword`",
23
+ text: tr("Wrong format. Use: `!note #keyword`", "صيغة غير صحيحة. استخدم: `!note #keyword`"),
17
24
  });
18
25
  }
19
26
 
@@ -25,7 +32,10 @@ module.exports = {
25
32
  await sock.sendMessage(groupId, { text: noteText });
26
33
  } else {
27
34
  await sock.sendMessage(groupId, {
28
- text: `⚠️ لم يتم العثور على ملاحظة بالكلمة المفتاحية: \`${keywordArg}\`\n\nلعرض كل الملاحظات، استخدم: \`!notes\``,
35
+ text: tr(
36
+ `⚠️ No note has the keyword \`${keywordArg}\`\n\nTo see every note, use: \`!notes\``,
37
+ `⚠️ لم يتم العثور على ملاحظة بالكلمة المفتاحية: \`${keywordArg}\`\n\nلعرض كل الملاحظات، استخدم: \`!notes\``,
38
+ ),
29
39
  });
30
40
  }
31
41
  },
@@ -1,10 +1,17 @@
1
1
  // file: /commands/promote.js
2
2
  const logger = require("../../utils/logger.cjs");
3
+ const { tr } = require("../../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "promote",
6
- description: "Promotes a member to an admin.",
7
- usage: "promote @عضو",
7
+ description: {
8
+ en: "Promotes a member to admin.",
9
+ ar: "يرقّي عضوًا إلى مشرف.",
10
+ },
11
+ usage: {
12
+ en: "promote @member",
13
+ ar: "promote @عضو",
14
+ },
8
15
  chat: "group",
9
16
  userAdminRequired: true,
10
17
  botAdminRequired: true,
@@ -19,7 +26,10 @@ module.exports = {
19
26
 
20
27
  if (!targetJid) {
21
28
  return await sock.sendMessage(groupId, {
22
- text: "يجب عمل منشن للعضو أو الرد على رسالته لترقيته.",
29
+ text: tr(
30
+ "Mention the member, or reply to their message, to promote them.",
31
+ "يجب عمل منشن للعضو أو الرد على رسالته لترقيته.",
32
+ ),
23
33
  });
24
34
  }
25
35
 
@@ -27,7 +37,10 @@ module.exports = {
27
37
  const targetUser = groupMetadata.participants.find((p) => p.id === targetJid);
28
38
  if (targetUser && (targetUser.admin === "admin" || targetUser.admin === "superadmin")) {
29
39
  return await sock.sendMessage(groupId, {
30
- text: `⚠️ العضو @${targetJid.split("@")[0]} مشرف بالفعل.`,
40
+ text: tr(
41
+ `⚠️ @${targetJid.split("@")[0]} is already an admin.`,
42
+ `⚠️ العضو @${targetJid.split("@")[0]} مشرف بالفعل.`,
43
+ ),
31
44
  mentions: [targetJid],
32
45
  });
33
46
  }
@@ -39,13 +52,16 @@ module.exports = {
39
52
  "promote", // The action is 'promote'
40
53
  );
41
54
  await sock.sendMessage(groupId, {
42
- text: `👑 تم ترقية @${targetJid.split("@")[0]} إلى مشرف بنجاح.`,
55
+ text: tr(
56
+ `👑 @${targetJid.split("@")[0]} is now an admin.`,
57
+ `👑 تم ترقية @${targetJid.split("@")[0]} إلى مشرف بنجاح.`,
58
+ ),
43
59
  mentions: [targetJid],
44
60
  });
45
61
  } catch (error) {
46
62
  logger.error({ err: error, command: "promote" }, "Error in !promote command");
47
63
  await sock.sendMessage(groupId, {
48
- text: "حدث خطأ أثناء محاولة الترقية.",
64
+ text: tr("Something went wrong while promoting.", "حدث خطأ أثناء محاولة الترقية."),
49
65
  });
50
66
  }
51
67
  },
@@ -1,10 +1,17 @@
1
1
  // file: /commands/removeall.js
2
2
  const logger = require("../../utils/logger.cjs");
3
+ const { tr } = require("../../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "removeall",
6
- description: "Removes all non-admin members from the group after confirmation.",
7
- usage: "removeall",
7
+ description: {
8
+ en: "Removes every non-admin member from the group, after confirmation.",
9
+ ar: "يطرد كل الأعضاء غير المشرفين من المجموعة بعد التأكيد.",
10
+ },
11
+ usage: {
12
+ en: "removeall",
13
+ ar: "removeall",
14
+ },
8
15
  chat: "group",
9
16
  userAdminRequired: true,
10
17
  botAdminRequired: true,
@@ -18,7 +25,10 @@ module.exports = {
18
25
 
19
26
  // Ask for confirmation
20
27
  await sock.sendMessage(groupId, {
21
- text: "⚠️ هل أنت متأكد من أنك تريد حذف جميع الأعضاء غير المشرفين؟\n\nأرسل `yes` للتأكيد خلال 30 ثانية.",
28
+ text: tr(
29
+ "⚠️ Are you sure you want to remove every non-admin member?\n\nSend `yes` within 30 seconds to confirm.",
30
+ "⚠️ هل أنت متأكد من أنك تريد حذف جميع الأعضاء غير المشرفين؟\n\nأرسل `yes` للتأكيد خلال 30 ثانية.",
31
+ ),
22
32
  });
23
33
 
24
34
  // Store the confirmation request
@@ -1,11 +1,18 @@
1
1
  // file: /commands/group/rules.js
2
2
  const { getGroupSettings } = require("../../utils/storage.cjs");
3
3
  const logger = require("../../utils/logger.cjs");
4
+ const { tr } = require("../../utils/i18n.cjs");
4
5
 
5
6
  module.exports = {
6
7
  name: "rules",
7
- description: "Displays the group rules.",
8
- usage: "rules",
8
+ description: {
9
+ en: "Shows the group rules.",
10
+ ar: "يعرض قواعد المجموعة.",
11
+ },
12
+ usage: {
13
+ en: "rules",
14
+ ar: "rules",
15
+ },
9
16
  chat: "group",
10
17
 
11
18
  async execute(sock, msg) {
@@ -16,16 +23,24 @@ module.exports = {
16
23
  const rules = settings.rules;
17
24
 
18
25
  if (rules) {
19
- const reply = `*📜 قواعد جروب ${msg.pushName}:*\n\n${rules}`;
26
+ const reply = tr(
27
+ `*📜 Rules of ${msg.pushName}'s group:*\n\n${rules}`,
28
+ `*📜 قواعد جروب ${msg.pushName}:*\n\n${rules}`,
29
+ );
20
30
  await sock.sendMessage(groupId, { text: reply });
21
31
  } else {
22
32
  await sock.sendMessage(groupId, {
23
- text: "لم يتم تعيين أي قواعد لهذا الجروب حتى الآن. يمكن للمشرفين تعيينها باستخدام `!setrules`.",
33
+ text: tr(
34
+ "This group has no rules yet. Admins can set them with `!setrules`.",
35
+ "لم يتم تعيين أي قواعد لهذا الجروب حتى الآن. يمكن للمشرفين تعيينها باستخدام `!setrules`.",
36
+ ),
24
37
  });
25
38
  }
26
39
  } catch (error) {
27
40
  logger.error(error, "[Error] in !rules command:");
28
- await sock.sendMessage(groupId, { text: "حدث خطأ أثناء جلب القواعد." });
41
+ await sock.sendMessage(groupId, {
42
+ text: tr("Something went wrong while fetching the rules.", "حدث خطأ أثناء جلب القواعد."),
43
+ });
29
44
  }
30
45
  },
31
46
  };
@@ -1,11 +1,18 @@
1
1
  // file: /commands/save.js
2
2
  const { saveNote } = require("../../utils/storage.cjs");
3
3
  const logger = require("../../utils/logger.cjs");
4
+ const { tr } = require("../../utils/i18n.cjs");
4
5
 
5
6
  module.exports = {
6
7
  name: "save",
7
- description: "Saves a new note for the group.",
8
- usage: "save #الكلمة-المفتاحية <نص الملاحظة>",
8
+ description: {
9
+ en: "Saves a new note for the group.",
10
+ ar: "يحفظ ملاحظة جديدة للمجموعة.",
11
+ },
12
+ usage: {
13
+ en: "save #keyword <note text>",
14
+ ar: "save #الكلمة-المفتاحية <نص الملاحظة>",
15
+ },
9
16
  chat: "group",
10
17
  userAdminRequired: true,
11
18
 
@@ -16,7 +23,10 @@ module.exports = {
16
23
 
17
24
  if (!keywordArg || !keywordArg.startsWith("#") || !noteText) {
18
25
  return await sock.sendMessage(groupId, {
19
- text: "صيغة غير صحيحة. استخدم:\n`!save #keyword نص الملاحظة`",
26
+ text: tr(
27
+ "Wrong format. Use:\n`!save #keyword note text`",
28
+ "صيغة غير صحيحة. استخدم:\n`!save #keyword نص الملاحظة`",
29
+ ),
20
30
  });
21
31
  }
22
32
 
@@ -26,11 +36,16 @@ module.exports = {
26
36
  // Simply call the new storage function
27
37
  saveNote(groupId, keyword, noteText);
28
38
  await sock.sendMessage(groupId, {
29
- text: `✅ تم حفظ الملاحظة بنجاح بالكلمة المفتاحية: \`#${keyword}\``,
39
+ text: tr(
40
+ `✅ Note saved under the keyword \`#${keyword}\``,
41
+ `✅ تم حفظ الملاحظة بنجاح بالكلمة المفتاحية: \`#${keyword}\``,
42
+ ),
30
43
  });
31
44
  } catch (error) {
32
45
  logger.error({ err: error, command: "save" }, "Error in !save command");
33
- await sock.sendMessage(groupId, { text: "حدث خطأ أثناء حفظ الملاحظة." });
46
+ await sock.sendMessage(groupId, {
47
+ text: tr("Something went wrong while saving the note.", "حدث خطأ أثناء حفظ الملاحظة."),
48
+ });
34
49
  }
35
50
  },
36
51
  };
@@ -1,10 +1,17 @@
1
1
  // file: /commands/group/setname.js
2
2
  const logger = require("../../utils/logger.cjs");
3
+ const { tr } = require("../../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "setname",
6
- description: "Changes the group's subject/name.",
7
- usage: "setname <الاسم الجديد>",
7
+ description: {
8
+ en: "Changes the group's name.",
9
+ ar: "يغيّر اسم المجموعة.",
10
+ },
11
+ usage: {
12
+ en: "setname <new name>",
13
+ ar: "setname <الاسم الجديد>",
14
+ },
8
15
  chat: "group",
9
16
  userAdminRequired: true,
10
17
  botAdminRequired: true,
@@ -15,26 +22,32 @@ module.exports = {
15
22
 
16
23
  if (!newName) {
17
24
  return await sock.sendMessage(groupId, {
18
- text: "يرجى كتابة الاسم الجديد للجروب بعد الأمر.",
25
+ text: tr("Write the group's new name after the command.", "يرجى كتابة الاسم الجديد للجروب بعد الأمر."),
19
26
  });
20
27
  }
21
28
 
22
29
  // WhatsApp has a limit of 25 characters for the subject
23
30
  if (newName.length > 25) {
24
31
  return await sock.sendMessage(groupId, {
25
- text: "⚠️ اسم الجروب طويل جدًا. الحد الأقصى هو 25 حرفًا.",
32
+ text: tr(
33
+ "⚠️ That name is too long. The limit is 25 characters.",
34
+ "⚠️ اسم الجروب طويل جدًا. الحد الأقصى هو 25 حرفًا.",
35
+ ),
26
36
  });
27
37
  }
28
38
 
29
39
  try {
30
40
  await sock.groupUpdateSubject(groupId, newName);
31
41
  await sock.sendMessage(groupId, {
32
- text: `✅ تم تغيير اسم الجروب بنجاح إلى:\n*${newName}*`,
42
+ text: tr(`✅ The group is now called:\n*${newName}*`, `✅ تم تغيير اسم الجروب بنجاح إلى:\n*${newName}*`),
33
43
  });
34
44
  } catch (error) {
35
45
  logger.error({ err: error }, "Error in !group setname command");
36
46
  await sock.sendMessage(groupId, {
37
- text: "حدث خطأ. تأكد من أنني مشرف ولدي صلاحية تغيير اسم الجروب.",
47
+ text: tr(
48
+ "Something went wrong. Make sure I'm an admin and allowed to change the group's name.",
49
+ "حدث خطأ. تأكد من أنني مشرف ولدي صلاحية تغيير اسم الجروب.",
50
+ ),
38
51
  });
39
52
  }
40
53
  },
@@ -1,11 +1,18 @@
1
1
  // file: /commands/group/setpp.js
2
2
  const { downloadMediaMessage } = require("@whiskeysockets/baileys");
3
3
  const logger = require("../../utils/logger.cjs");
4
+ const { tr } = require("../../utils/i18n.cjs");
4
5
 
5
6
  module.exports = {
6
7
  name: "setpp", // pp = profile picture
7
- description: "Changes the group's profile picture.",
8
- usage: "setpp (رد على صورة)",
8
+ description: {
9
+ en: "Changes the group's profile picture.",
10
+ ar: "يغيّر صورة المجموعة.",
11
+ },
12
+ usage: {
13
+ en: "setpp (reply to an image)",
14
+ ar: "setpp (رد على صورة)",
15
+ },
9
16
  chat: "group",
10
17
  userAdminRequired: true,
11
18
  botAdminRequired: true,
@@ -17,12 +24,17 @@ module.exports = {
17
24
  const quoted = msg.message?.extendedTextMessage?.contextInfo?.quotedMessage;
18
25
  if (!quoted || !quoted.imageMessage) {
19
26
  return await sock.sendMessage(groupId, {
20
- text: "لتغيير صورة الجروب، يرجى الرد على الصورة التي تريدها بهذا الأمر.",
27
+ text: tr(
28
+ "To change the group's picture, reply to the image you want with this command.",
29
+ "لتغيير صورة الجروب، يرجى الرد على الصورة التي تريدها بهذا الأمر.",
30
+ ),
21
31
  });
22
32
  }
23
33
 
24
34
  try {
25
- await sock.sendMessage(groupId, { text: "🖼️ جاري تغيير صورة الجروب..." });
35
+ await sock.sendMessage(groupId, {
36
+ text: tr("🖼️ Changing the group's picture...", "🖼️ جاري تغيير صورة الجروب..."),
37
+ });
26
38
 
27
39
  // Download the image from the quoted message
28
40
  const imageBuffer = await downloadMediaMessage(
@@ -39,12 +51,15 @@ module.exports = {
39
51
  await sock.updateProfilePicture(groupId, imageBuffer);
40
52
 
41
53
  await sock.sendMessage(groupId, {
42
- text: "✅ تم تحديث صورة الجروب بنجاح.",
54
+ text: tr("✅ The group's picture was updated.", "✅ تم تحديث صورة الجروب بنجاح."),
43
55
  });
44
56
  } catch (error) {
45
57
  logger.error({ err: error }, "Error in !group setpp command");
46
58
  await sock.sendMessage(groupId, {
47
- text: "حدث خطأ. تأكد من أنني مشرف وأن الصورة صالحة.",
59
+ text: tr(
60
+ "Something went wrong. Make sure I'm an admin and the image is valid.",
61
+ "حدث خطأ. تأكد من أنني مشرف وأن الصورة صالحة.",
62
+ ),
48
63
  });
49
64
  }
50
65
  },
@@ -1,10 +1,17 @@
1
1
  const { getGroupSettings, saveGroupSettings } = require("../../utils/storage.cjs");
2
2
  const logger = require("../../utils/logger.cjs");
3
+ const { tr } = require("../../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "setrules",
6
- description: "Sets the rules for the current group.",
7
- usage: "setrules <القواعد>",
7
+ description: {
8
+ en: "Sets the rules for this group.",
9
+ ar: "يضبط قواعد هذه المجموعة.",
10
+ },
11
+ usage: {
12
+ en: "setrules <rules>",
13
+ ar: "setrules <القواعد>",
14
+ },
8
15
  chat: "group",
9
16
  userAdminRequired: true,
10
17
 
@@ -14,7 +21,10 @@ module.exports = {
14
21
 
15
22
  if (!rulesText) {
16
23
  return await sock.sendMessage(groupId, {
17
- text: "يرجى كتابة القواعد بعد الأمر.\n*مثال:*\n`!setrules 1. احترام الأعضاء.\n2. ممنوع السبام.`",
24
+ text: tr(
25
+ "Write the rules after the command.\n*Example:*\n`!setrules 1. Respect the members.\n2. No spam.`",
26
+ "يرجى كتابة القواعد بعد الأمر.\n*مثال:*\n`!setrules 1. احترام الأعضاء.\n2. ممنوع السبام.`",
27
+ ),
18
28
  });
19
29
  }
20
30
 
@@ -29,12 +39,14 @@ module.exports = {
29
39
  saveGroupSettings(groupId, settings);
30
40
 
31
41
  await sock.sendMessage(groupId, {
32
- text: "✅ تم حفظ قواعد الجروب بنجاح في قاعدة البيانات.",
42
+ text: tr("✅ The group's rules were saved.", "✅ تم حفظ قواعد الجروب بنجاح في قاعدة البيانات."),
33
43
  });
34
44
  } catch (error) {
35
45
  // Improved logging for better debugging
36
46
  logger.error({ err: error, groupId: groupId }, "Error in !setrules command");
37
- await sock.sendMessage(groupId, { text: "حدث خطأ أثناء حفظ القواعد." });
47
+ await sock.sendMessage(groupId, {
48
+ text: tr("Something went wrong while saving the rules.", "حدث خطأ أثناء حفظ القواعد."),
49
+ });
38
50
  }
39
51
  },
40
52
  };
@@ -1,10 +1,17 @@
1
1
  // file: /commands/group/setwarn.js
2
2
  const { getGroupSettings, saveGroupSettings } = require("../../utils/storage.cjs");
3
+ const { tr } = require("../../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "setwarn",
6
- description: "Configures the automatic warning system.",
7
- usage: "setwarn max <عدد>\nsetwarn action <KICK|NONE>",
7
+ description: {
8
+ en: "Configures the automatic warning system.",
9
+ ar: "يضبط نظام التحذيرات التلقائي.",
10
+ },
11
+ usage: {
12
+ en: "setwarn max <count>\nsetwarn action <KICK|NONE>",
13
+ ar: "setwarn max <عدد>\nsetwarn action <KICK|NONE>",
14
+ },
8
15
  chat: "group",
9
16
  userAdminRequired: true,
10
17
 
@@ -25,12 +32,15 @@ module.exports = {
25
32
  const max = parseInt(value, 10);
26
33
  if (isNaN(max) || max < 1) {
27
34
  return await sock.sendMessage(groupId, {
28
- text: "يرجى تحديد عدد صحيح وصالح للحد الأقصى للتحذيرات.",
35
+ text: tr(
36
+ "Give a valid whole number for the warning limit.",
37
+ "يرجى تحديد عدد صحيح وصالح للحد الأقصى للتحذيرات.",
38
+ ),
29
39
  });
30
40
  }
31
41
  warnConfig.max_warnings = max;
32
42
  await sock.sendMessage(groupId, {
33
- text: `✅ تم تعيين الحد الأقصى للتحذيرات إلى ${max}.`,
43
+ text: tr(`✅ The warning limit is now ${max}.`, `✅ تم تعيين الحد الأقصى للتحذيرات إلى ${max}.`),
34
44
  });
35
45
  break;
36
46
  }
@@ -39,19 +49,25 @@ module.exports = {
39
49
  const action = value?.toUpperCase();
40
50
  if (action !== "KICK" && action !== "NONE") {
41
51
  return await sock.sendMessage(groupId, {
42
- text: "الإجراء غير صالح. الإجراءات المتاحة: `KICK`, `NONE`",
52
+ text: tr(
53
+ "Invalid action. Available: `KICK`, `NONE`",
54
+ "الإجراء غير صالح. الإجراءات المتاحة: `KICK`, `NONE`",
55
+ ),
43
56
  });
44
57
  }
45
58
  warnConfig.action = action;
46
59
  await sock.sendMessage(groupId, {
47
- text: `✅ تم تعيين الإجراء التلقائي إلى ${action}.`,
60
+ text: tr(`✅ The automatic action is now ${action}.`, `✅ تم تعيين الإجراء التلقائي إلى ${action}.`),
48
61
  });
49
62
  break;
50
63
  }
51
64
 
52
65
  default:
53
66
  return await sock.sendMessage(groupId, {
54
- text: "صيغة غير صحيحة. استخدم:\n`!setwarn max <number>`\n`!setwarn action <KICK|NONE>`",
67
+ text: tr(
68
+ "Wrong format. Use:\n`!setwarn max <number>`\n`!setwarn action <KICK|NONE>`",
69
+ "صيغة غير صحيحة. استخدم:\n`!setwarn max <number>`\n`!setwarn action <KICK|NONE>`",
70
+ ),
55
71
  });
56
72
  }
57
73