-
Notifications
You must be signed in to change notification settings - Fork 14
/
susunkata.js
35 lines (33 loc) · 1.14 KB
/
susunkata.js
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
let fetch = require('node-fetch')
let timeout = 120000
let poin = 500
let handler = async (m, { conn, usedPrefix }) => {
conn.susunkata = conn.susunkata ? conn.susunkata : {}
let id = m.chat
if (id in conn.susunkata) {
conn.reply(m.chat, 'Masih ada soal belum terjawab di chat ini', conn.susunkata[id][0])
throw false
}
let res = await fetch(global.API('xteam', '/game/susunkata', {}, 'APIKEY'))
if (res.status !== 200) throw await res.text()
let json = await res.json()
if (!json.status) throw json
let caption = `*Level:* ${json.result.level}
${json.result.soal}
Timeout *${(timeout / 1000).toFixed(2)} detik*
Ketik ${usedPrefix}suska untuk bantuan
Bonus: ${poin} XP
`.trim()
conn.susunkata[id] = [
await conn.reply(m.chat, caption, m),
json, poin,
setTimeout(() => {
if (conn.susunkata[id]) conn.reply(m.chat, `Waktu habis!\nJawabannya adalah *${json.result.jawaban}*`, conn.susunkata[id][0])
delete conn.susunkata[id]
}, timeout)
]
}
handler.help = ['susunkata']
handler.tags = ['game']
handler.command = /^susunkata/i
module.exports = handler