MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MDX / modeCommand

Function modeCommand

plugins/mode.ts:12–102  ·  view source on GitHub ↗

* Advanced bot mode system with multiple access control options * Modes: * - public: Everyone can use (groups + private) * - private: Owner/sudo only * - groups: Only works in groups (everyone in groups) * - inbox: Only works in private chats (everyone in DM) * - self: Owner/sudo only (alias f

(sock: any, message: any, args: any, context: any)

Source from the content-addressed store, hash-verified

10 * - self: Owner/sudo only (alias for private)
11 */
12async function modeCommand(sock: any, message: any, args: any, context: any) {
13 const { chatId, channelInfo } = context
14
15 const _senderId = message.key.participant || message.key.remoteJid
16 const isOwnerOrSudoCheck = message.key.fromMe || context.senderIsOwnerOrSudo || context.isOwnerOrSudoCheck
17
18 if (!isOwnerOrSudoCheck) {
19 return await sock.sendMessage(chatId, {
20 text: '❌ Only the owner or sudo users can change bot mode!',
21 ...channelInfo
22 }, { quoted: message })
23 }
24
25 const subCommand = args[0]?.toLowerCase()
26 const currentMode = await store.getBotMode() || 'public'
27
28 if (!subCommand || subCommand === 'status' || subCommand === 'check') {
29 const modeEmojis: Record<string, string> = {
30 public: '🌍',
31 private: '🔒',
32 groups: '👥',
33 inbox: '💬',
34 self: '👤'
35 }
36
37 const modeDescriptions: Record<string, string> = {
38 public: 'Everyone can use bot (groups + private chats)',
39 private: 'Only owner and sudo users can use bot',
40 groups: 'Only works in group chats (everyone in groups)',
41 inbox: 'Only works in private chats (everyone in DMs)',
42 self: 'Owner and sudo only (same as private)'
43 }
44
45 let statusText = `📊 *BOT MODE STATUS*\n\n`
46 statusText += `Current Mode: ${modeEmojis[currentMode]} *${currentMode.toUpperCase()}*\n`
47 statusText += `Description: ${modeDescriptions[currentMode]}\n\n`
48 statusText += `━━━━━━━━━━━━━━━━━━━━\n\n`
49 statusText += `*Available Modes:*\n\n`
50
51 Object.entries(modeDescriptions).forEach(([mode, desc]) => {
52 const current = mode === currentMode ? '✓ ' : ''
53 statusText += `${current}${modeEmojis[mode]} \`${mode}\`\n${desc}\n\n`
54 })
55
56 statusText += `*Usage:*\n`
57 statusText += `• \`.mode <mode>\` - Change mode\n`
58 statusText += `• \`.mode status\` - Show current mode\n\n`
59 statusText += `*Examples:*\n`
60 statusText += `• \`.mode public\` - Enable for everyone\n`
61 statusText += `• \`.mode groups\` - Groups only\n`
62 statusText += `• \`.mode inbox\` - Private chats only\n`
63 statusText += `• \`.mode private\` - Owner/sudo only`
64
65 return await sock.sendMessage(chatId, {
66 text: statusText,
67 ...channelInfo
68 }, { quoted: message })
69 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected