-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathvote-vote.js
38 lines (33 loc) · 1.17 KB
/
vote-vote.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
36
37
38
let handler = async (m, { conn, usedPrefix, command }) => {
let id = m.chat
conn.vote = conn.vote ? conn.vote : {}
if (!(id in conn.vote)) throw `_*tidak ada voting digrup ini!*_\n\n*${usedPrefix}mulaivote* - untuk memulai vote`
let isVote = conn.vote[id][1].concat(conn.vote[id][2])
const wasVote = isVote.includes(m.sender)
if (wasVote) throw 'Kamu sudah vote!'
if (/up/i.test(command)) {
conn.vote[id][1].push(m.sender)
} else if (/de/i.test(command)) {
conn.vote[id][2].push(m.sender)
}
m.reply(`Done!\n\n*${usedPrefix}cekvote* - untuk mengecek vote`)
let [reason, upvote, devote] = conn.vote[id]
let mentionedJid = [...upvote, ...devote]
m.reply(`
*「 VOTE 」*
*Alasan:* ${reason}
*UPVOTE*
_Total: ${upvote.length}_
${upvote.map(u => '@' + u.split('@')[0]).join('\n')}
*DEVOTE*
_Total: ${devote.length}_
${devote.map(u => '@' + u.split('@')[0]).join('\n')}
*${usedPrefix}hapusvote* - untuk menghapus vote
_by Raditya_
`.trim(), false, { contextInfo: { mentionedJid } })
}
handler.help = ['upvote', 'devote']
handler.tags = ['vote']
handler.command = /^(up|de)vote$/i
handler.group = true
module.exports = handler