rpg-rob.js 1.9 KB

123456789101112131415161718192021222324252627282930313233
  1. let ro = 3000
  2. let handler = async (m, { conn, usedPrefix, command}) => {
  3. let time = global.db.data.users[m.sender].lastrob + 7200000
  4. if (new Date - global.db.data.users[m.sender].lastrob < 7200000) throw `🚓 La policía que esta vigilando, vuelve en: ${msToTime(time - new Date())}\n\n‍`
  5. let who
  6. if (m.isGroup) who = m.mentionedJid[0] ? m.mentionedJid[0] : m.quoted ? m.quoted.sender : false
  7. else who = m.chat
  8. if (!who) return conn.reply(m.chat, `*⚠️ Etiqueta a un usuario para robar*`, m, {contextInfo: {externalAdReply :{ mediaUrl: null, mediaType: 1, description: null, title: wm, body: '', previewType: 0, thumbnail: img.getRandom(), sourceUrl: redes.getRandom()}}})
  9. if (!(who in global.db.data.users)) throw `*⚠️ ¿Quien carajo es? No aparece el mi base de datos.*`
  10. let users = global.db.data.users[who]
  11. let rob = Math.floor(Math.random() * ro)
  12. if (users.exp < rob) return m.reply(`@${who.split`@`[0]} Este usuario tiene menos de ${ro} XP\n> No robes a un pobre v:`, null, { mentions: [who] })
  13. global.db.data.users[m.sender].exp += rob
  14. global.db.data.users[who].exp -= rob
  15. m.reply(`*Robaste ${rob} XP a @${who.split`@`[0]}*`, null, { mentions: [who] })
  16. //conn.sendMessage(m.chat, {text: `*Robaste ${rob} XP a @${who.split`@`[0]}*`, contextInfo:{ mentions: [who]}}, { quoted: m})
  17. global.db.data.users[m.sender].lastrob = new Date * 1
  18. }
  19. handler.help = ['rob']
  20. handler.tags = ['econ']
  21. handler.command = ['robar', 'rob']
  22. handler.register = true
  23. export default handler
  24. function msToTime(duration) {
  25. var milliseconds = parseInt((duration % 1000) / 100),
  26. seconds = Math.floor((duration / 1000) % 60),
  27. minutes = Math.floor((duration / (1000 * 60)) % 60),
  28. hours = Math.floor((duration / (1000 * 60 * 60)) % 24)
  29. hours = (hours < 10) ? "0" + hours : hours
  30. minutes = (minutes < 10) ? "0" + minutes : minutes
  31. seconds = (seconds < 10) ? "0" + seconds : seconds
  32. return hours + " Hora(s) " + minutes + " Minuto(s)"}