เขียนคำสั่งแรก
ใน Dashboard สามารถเพิ่มคำสั่งที่สร้างขึ้นเองได้ผ่านหน้า Custom Commands โค้ดเขียนเป็น JavaScript และทำงานได้ทุกแพลตฟอร์มที่มะนาวรองรับในคราวเดียว

Context ที่ใช้งานได้
Section titled “Context ที่ใช้งานได้”มะนาวรัน custom command ในสภาพแวดล้อมที่มี context และ args ให้ใช้:
// ข้อมูลผู้ใช้context.user.name // ชื่อผู้ใช้context.user.id // Manao User ID (ใช้เชื่อมบัญชีข้ามแพลตฟอร์ม)context.user.platform // แพลตฟอร์ม ("twitch" | "kick" | "discord" | "youtube")context.user.platformID // User ID ของแพลตฟอร์มนั้น ๆcontext.user.roles.isFollowercontext.user.roles.isSubscribercontext.user.roles.isVIPcontext.user.roles.isModeratorcontext.user.roles.isBroadcaster
// ข้อมูลทั่วไปcontext.channel // ชื่อช่องcontext.language // ภาษาบอต ("en" | "th")context.currency // ชื่อสกุลเงิน
// ส่งข้อความawait context.say("...") // ส่งข้อความในแชทawait context.reply("...") // ตอบกลับพร้อมแท็กชื่อผู้ใช้await context.whisper("...") // ส่งข้อความส่วนตัว (ถ้าแพลตฟอร์มรองรับ)
// อื่น ๆawait context.lookupUser("name") // ค้นหา user จากชื่อ คืน id หรือ nullcontext.emit("event", data) // ส่ง event ไปยัง overlay
// อาร์กิวเมนต์ที่ผู้ใช้พิมพ์มาargs[0], args[1], ... // เช่น !hello โลก → args[0] = "โลก"การตอบกลับอย่างง่าย
Section titled “การตอบกลับอย่างง่าย”!hello [name] — ทักทายผู้ใช้
const name = args[0] || `@${context.user.name}`;await context.say(`สวัสดี ${name}!`);!roll — ทอยลูกเต๋า
const result = Math.ceil(Math.random() * 6);await context.say(`🎲 ได้เลข: ${result}`);!dish — สุ่มรายชื่ออาหาร
const dishes = ["ข้าวกะเพรา", "ผัดไทย", "ข้าวซอย", "ข้าวเหนียวมะม่วง"];const dish = dishes[Math.floor(Math.random() * dishes.length)];await context.say(`🍲 วันนี้กิน: ${dish}!`);การจัดการยอดเงิน
Section titled “การจัดการยอดเงิน”!transfer <user> <amount> — โอนเงินให้ผู้ใช้อื่น
const targetName = args[0];const amount = parseInt(args[1], 10);
if (!targetName || isNaN(amount) || amount <= 0) { await context.reply("วิธีใช้: !transfer <ชื่อผู้ใช้> <จำนวน>"); return;}
const targetId = await context.lookupUser(targetName);if (!targetId) { await context.reply(`ไม่พบผู้ใช้ ${targetName}`); return;}
// ใช้ context.emit เพื่อส่งข้อมูลไปยัง overlay หรือ event handler อื่นcontext.emit("transfer", { from: context.user.id, to: targetId, amount,});
await context.reply(`โอน ${amount} ${context.currency} ให้ @${targetName} เรียบร้อย`);มินิเกม
Section titled “มินิเกม”!rps <ค้อน/กระดาษ/กรรไกร> — เป่ายิ้งฉุบ
const map = { "ค้อน": "rock", "กระดาษ": "paper", "กรรไกร": "scissors" };const revMap = { "rock": "ค้อน", "paper": "กระดาษ", "scissors": "กรรไกร" };const choices = ["rock", "paper", "scissors"];
const userChoice = map[args[0]];if (!userChoice) { await context.reply("วิธีใช้: !rps [ค้อน/กระดาษ/กรรไกร]"); return;}
const botChoice = choices[Math.floor(Math.random() * choices.length)];let result = "เสมอ!";if ( (userChoice === "rock" && botChoice === "scissors") || (userChoice === "paper" && botChoice === "rock") || (userChoice === "scissors" && botChoice === "paper")) result = "ชนะ! 🎉";else if (userChoice !== botChoice) result = "แพ้! 😢";
await context.say(`✊✋✌️ ${context.user.name} เลือก ${args[0]}, บอตเลือก ${revMap[botChoice]}. ${result}`);