rpg-transfer.js 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const items = ['limit', 'exp', 'joincount', 'money', 'potion', 'trash', 'wood', 'rock', 'string', 'petFood', 'emerald', 'diamond', 'gold', 'iron', 'common', 'uncoommon', 'mythic', 'legendary', 'pet', ]
  2. let confirmation = {}
  3. async function handler(m, { conn, args, usedPrefix, command }) {
  4. if (confirmation[m.sender]) return m.reply('𝙀𝙨𝙩𝙖𝙨 𝙝𝙖𝙘𝙞𝙚𝙣𝙙𝙤 𝙪𝙣𝙖 𝙩𝙧𝙖𝙣𝙨𝙛𝙚𝙧𝙚𝙣𝙘𝙞𝙖')
  5. let user = global.db.data.users[m.sender]
  6. const item = items.filter(v => v in user && typeof user[v] == 'number')
  7. let lol = `\`⧼⧼⧼ 💱 𝙏𝙍𝘼𝙉𝙎𝙁𝙀𝙍𝙀𝙉𝘾𝙄𝘼 💱 ⧽⧽⧽\`
  8. > *${usedPrefix + command} tipo cantidad @tag*
  9. \`❏ 𝙀𝙅𝙀𝙈𝙋𝙇𝙊 :\`
  10. * *${usedPrefix + command} exp 30 @0*
  11. ┏•「 *✅ 𝙍𝙀𝘾𝙐𝙍𝙎𝙊𝙎 𝘿𝙄𝙎𝙋𝙊𝙉𝙄𝘽𝙇𝙀𝙎* 」
  12. ┃ 💎 𝘿𝙞𝙖𝙢𝙖𝙣𝙩𝙚𝙨 = limit
  13. ┃ 🪙 𝐊𝐚𝐧𝐭𝐮𝘾𝙤𝙞𝙣𝙨 = money
  14. ┃ ⚡ 𝙀𝙭𝙥𝙚𝙧𝙞𝙚𝙣𝙘𝙞𝙖 = exp
  15. ┗•`.trim()
  16. const type = (args[0] || '').toLowerCase()
  17. if (!item.includes(type)) return m.reply(lol, m.chat, {mentions: conn.parseMention(lol)}, {quoted: m })
  18. const count = Math.min(Number.MAX_SAFE_INTEGER, Math.max(1, (isNumber(args[1]) ? parseInt(args[1]) : 1))) * 1
  19. let who = m.mentionedJid && m.mentionedJid[0] ? m.mentionedJid[0] : args[2] ? (args[2].replace(/[@ .+-]/g, '') + '@s.whatsapp.net') : ''
  20. if (!who) return m.reply(`${ag} *𝙀𝙏𝙄𝙌𝙐𝙀𝙏𝙀 𝘼𝙇 𝙐𝙎𝙐𝘼𝙍𝙄𝙊*`)
  21. if (!(who in global.db.data.users)) return m.reply(`${fg}*𝙀𝙇 𝙐𝙎𝙐𝘼𝙍𝙄𝙊 ${who} 𝙉𝙊 𝙎𝙀 𝙀𝙉𝘾𝙐𝙀𝙉𝙏𝙍𝘼 𝙀𝙉 𝙈𝙄 𝘽𝘼𝙎𝙀 𝘿𝙀 𝘿𝘼𝙏𝙊𝙎*`)
  22. if (user[type] * 1 < count) return m.reply(`${fg}*𝙉𝙊 𝙏𝙄𝙀𝙉𝙀 𝙎𝙐𝙁𝙐𝘾𝙄𝙀𝙉𝙏𝙀 𝙋𝘼𝙍𝘼 𝙍𝙀𝘼𝙇𝙄𝙕𝘼𝙍 𝙇𝘼 𝙏𝙍𝘼𝙉𝙎𝙁𝙀𝙍𝙀𝙉𝘾𝙄𝘼 𝘿𝙀 ${type}*`)
  23. let mentionedJid = [who]
  24. let username = conn.getName(who)
  25. let confirm = `\`ESTAS A PUNTO DE HACER ESTA ACCIÓN DE TRANFERENCIA\`
  26. > 💹 *${count} ${type} para* *@${(who || '').replace(/@s\.whatsapp\.net/g, '')}* ?
  27. \`DESEAS CONTINUAR?\`
  28. > Tienes 60 segundos!!
  29. > Escriba: (si) para acertar
  30. > escriba: (no) para cancelar\n\n> ${wm}`.trim()
  31. let c = `${wm}\nTienes 60 segundos!!`
  32. await conn.reply(m.chat, confirm, m, { mentions: [who] })
  33. //conn.sendButton(m.chat, confirm, c, null, [['𝙎𝙄'], ['𝙉𝙊']], m, { mentions: [who] })
  34. confirmation[m.sender] = {sender: m.sender, to: who, message: m, type, count, timeout: setTimeout(() => (m.reply('*SU TIEMPO SE HA TERMINADO*'), delete confirmation[m.sender]), 60 * 1000)}}
  35. handler.before = async m => {
  36. if (m.isBaileys) return
  37. if (!(m.sender in confirmation)) return
  38. if (!m.text) return
  39. let { timeout, sender, message, to, type, count } = confirmation[m.sender]
  40. if (m.id === message.id) return
  41. let user = global.db.data.users[sender]
  42. let _user = global.db.data.users[to]
  43. if (/^No|no$/i.test(m.text) ) {
  44. //if (/No?/m.text(m.text.toLowerCase())) {
  45. clearTimeout(timeout)
  46. delete confirmation[sender]
  47. return m.reply('*CANCELADO*')
  48. }
  49. if (/^Si|si$/i.test(m.text) ) {
  50. //if (/Si?/m.text(m.text.toLowerCase())) {
  51. let previous = user[type] * 1
  52. let _previous = _user[type] * 1
  53. user[type] -= count * 1
  54. _user[type] += count * 1
  55. if (previous > user[type] * 1 && _previous < _user[type] * 1) m.reply(`✅ *TRANSFERENCIA HECHA CON ÉXITO:*\n\n*${count} ${type} para* @${(to || '').replace(/@s\.whatsapp\.net/g, '')}`, null, { mentions: [to] })
  56. else {
  57. user[type] = previous
  58. _user[type] = _previous
  59. m.reply(`*Error al transferir ${count} ${type} para* *@${(to || '').replace(/@s\.whatsapp\.net/g, '')}*`, null, { mentions: [to] })
  60. }
  61. clearTimeout(timeout)
  62. delete confirmation[sender]
  63. }}
  64. handler.help = ['transfer'].map(v => v + ' [tipo] [cantidad] [@tag]')
  65. handler.tags = ['econ'];
  66. handler.command = ['payxp', 'transfer', 'darxp', 'dar', 'enviar', 'transferir']
  67. handler.disabled = false
  68. handler.register = true
  69. export default handler
  70. function special(type) {
  71. let b = type.toLowerCase()
  72. let special = (['common', 'uncoommon', 'mythic', 'legendary', 'pet'].includes(b) ? ' Crate' : '')
  73. return special
  74. }
  75. function isNumber(x) {
  76. return !isNaN(x)
  77. }