File size: 2,507 Bytes
9d1558c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | const axios = require("axios");
const { getStreamFromURL } = global.utils;
module.exports = {
config: {
name: "dhbc",
version: "1.2",
author: "NTKhang",
countDown: 5,
role: 0,
shortDescription: {
vi: "game đuổi hình bắt chữ",
en: "game catch the word"
},
longDescription: {
vi: "chơi game đuổi hình bắt chữ",
en: "play game catch the word"
},
category: "game",
guide: {
en: "{pn}"
},
envConfig: {
reward: 1000
}
},
langs: {
vi: {
reply: "Hãy reply tin nhắn này với câu trả lời\n%1",
isSong: "Đây là tên bài hát của ca sĩ %1",
notPlayer: "⚠️ Bạn không phải là người chơi của câu hỏi này",
correct: "🎉 Chúc mừng bạn đã trả lời đúng và nhận được %1$",
wrong: "⚠️ Bạn đã trả lời sai"
},
en: {
reply: "Please reply this message with the answer\n%1",
isSong: "This is the name of the song of the singer %1",
notPlayer: "⚠️ You are not the player of this question",
correct: "🎉 Congratulations you have answered correctly and received %1$",
wrong: "⚠️ You have answered incorrectly"
}
},
onStart: async function ({ message, event, commandName, getLang }) {
const datagame = (await axios.get("https://goatbotserver.onrender.com/api/duoihinhbatchu")).data;
const { wordcomplete, casi, image1, image2 } = datagame.data;
message.reply({
body: getLang("reply", wordcomplete.replace(/\S/g, "█ ")) + (casi ? getLang("isSong", casi) : ''),
attachment: [
await getStreamFromURL(image1),
await getStreamFromURL(image2)
]
}, (err, info) => {
global.GoatBot.onReply.set(info.messageID, {
commandName,
messageID: info.messageID,
author: event.senderID,
wordcomplete
});
});
},
onReply: async ({ message, Reply, event, getLang, usersData, envCommands, commandName }) => {
const { author, wordcomplete, messageID } = Reply;
if (event.senderID != author)
return message.reply(getLang("notPlayer"));
if (formatText(event.body) == formatText(wordcomplete)) {
global.GoatBot.onReply.delete(messageID);
await usersData.addMoney(event.senderID, envCommands[commandName].reward);
message.reply(getLang("correct", envCommands[commandName].reward));
}
else
message.reply(getLang("wrong"));
}
};
function formatText(text) {
return text.normalize("NFD")
.toLowerCase()
.replace(/[\u0300-\u036f]/g, "")
.replace(/[đ|Đ]/g, (x) => x == "đ" ? "d" : "D");
} |