MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / handler

Function handler

plugins/hangman.js:42–62  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

40 description: 'Play hangman word guessing game',
41 usage: '.hangman to start, then .guess <letter>',
42 async handler(sock, message, args, context) {
43 const chatId = context.chatId || message.key.remoteJid;
44 const word = words[Math.floor(Math.random() * words.length)];
45 const maskedWord = '_ '.repeat(word.length).trim();
46 hangmanGames[chatId] = {
47 word,
48 maskedWord: maskedWord.split(' '),
49 guessedLetters: [],
50 wrongGuesses: 0,
51 maxWrongGuesses: 6,
52 };
53 await sock.sendMessage(chatId, {
54 text: `🎮 *HANGMAN GAME STARTED!*\n\n` +
55 `The word is: ${maskedWord}\n\n` +
56 `*How to play:*\n` +
57 `• Use \`.guess <letter>\` to guess\n` +
58 `• You have 6 wrong guesses allowed\n` +
59 `• Guess the word before running out of tries!\n\n` +
60 `Good luck! 🍀`
61 }, { quoted: message });
62 },
63 guessLetter
64};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected