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. โ”ƒ
  13. โ”ƒ ๐Ÿ’Ž ๐˜ฟ๐™ž๐™–๐™ข๐™–๐™ฃ๐™ฉ๐™š๐™จ = limit
  14. โ”ƒ ๐Ÿช™ ๐Š๐š๐ง๐ญ๐ฎ๐˜พ๐™ค๐™ž๐™ฃ๐™จ = money
  15. โ”ƒ โšก ๐™€๐™ญ๐™ฅ๐™š๐™ง๐™ž๐™š๐™ฃ๐™˜๐™ž๐™– = exp
  16. โ”—โ€ข`.trim()
  17. const type = (args[0] || '').toLowerCase()
  18. if (!item.includes(type)) return m.reply(lol, m.chat, {mentions: conn.parseMention(lol)}, {quoted: m })
  19. const count = Math.min(Number.MAX_SAFE_INTEGER, Math.max(1, (isNumber(args[1]) ? parseInt(args[1]) : 1))) * 1
  20. let who = m.mentionedJid && m.mentionedJid[0] ? m.mentionedJid[0] : args[2] ? (args[2].replace(/[@ .+-]/g, '') + '@s.whatsapp.net') : ''
  21. if (!who) return m.reply(`${ag} *๐™€๐™๐™„๐™Œ๐™๐™€๐™๐™€ ๐˜ผ๐™‡ ๐™๐™Ž๐™๐˜ผ๐™๐™„๐™Š*`)
  22. if (!(who in global.db.data.users)) return m.reply(`${fg}*๐™€๐™‡ ๐™๐™Ž๐™๐˜ผ๐™๐™„๐™Š ${who} ๐™‰๐™Š ๐™Ž๐™€ ๐™€๐™‰๐˜พ๐™๐™€๐™‰๐™๐™๐˜ผ ๐™€๐™‰ ๐™ˆ๐™„ ๐˜ฝ๐˜ผ๐™Ž๐™€ ๐˜ฟ๐™€ ๐˜ฟ๐˜ผ๐™๐™Š๐™Ž*`)
  23. if (user[type] * 1 < count) return m.reply(`${fg}*๐™‰๐™Š ๐™๐™„๐™€๐™‰๐™€ ๐™Ž๐™๐™๐™๐˜พ๐™„๐™€๐™‰๐™๐™€ ๐™‹๐˜ผ๐™๐˜ผ ๐™๐™€๐˜ผ๐™‡๐™„๐™•๐˜ผ๐™ ๐™‡๐˜ผ ๐™๐™๐˜ผ๐™‰๐™Ž๐™๐™€๐™๐™€๐™‰๐˜พ๐™„๐˜ผ ๐˜ฟ๐™€ ${type}*`)
  24. let mentionedJid = [who]
  25. let username = conn.getName(who)
  26. let confirm = `\`ESTAS A PUNTO DE HACER ESTA ACCIร“N DE TRANFERENCIA\`
  27. > ๐Ÿ’น *${count} ${type} para* *@${(who || '').replace(/@s\.whatsapp\.net/g, '')}* ?
  28. \`DESEAS CONTINUAR?\`
  29. > Tienes 60 segundos!!
  30. > Escriba: (si) para acertar
  31. > escriba: (no) para cancelar\n\n> ${wm}`.trim()
  32. let c = `${wm}\nTienes 60 segundos!!`
  33. await conn.reply(m.chat, confirm, m, { mentions: [who] })
  34. //conn.sendButton(m.chat, confirm, c, null, [['๐™Ž๐™„'], ['๐™‰๐™Š']], m, { mentions: [who] })
  35. 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)}}
  36. handler.before = async m => {
  37. if (m.isBaileys) return
  38. if (!(m.sender in confirmation)) return
  39. if (!m.text) return
  40. let { timeout, sender, message, to, type, count } = confirmation[m.sender]
  41. if (m.id === message.id) return
  42. let user = global.db.data.users[sender]
  43. let _user = global.db.data.users[to]
  44. if (/^No|no$/i.test(m.text) ) {
  45. //if (/No?/m.text(m.text.toLowerCase())) {
  46. clearTimeout(timeout)
  47. delete confirmation[sender]
  48. return m.reply('*CANCELADO*')
  49. }
  50. if (/^Si|si$/i.test(m.text) ) {
  51. //if (/Si?/m.text(m.text.toLowerCase())) {
  52. let previous = user[type] * 1
  53. let _previous = _user[type] * 1
  54. user[type] -= count * 1
  55. _user[type] += count * 1
  56. 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] })
  57. else {
  58. user[type] = previous
  59. _user[type] = _previous
  60. m.reply(`*Error al transferir ${count} ${type} para* *@${(to || '').replace(/@s\.whatsapp\.net/g, '')}*`, null, { mentions: [to] })
  61. }
  62. clearTimeout(timeout)
  63. delete confirmation[sender]
  64. }}
  65. handler.help = ['transfer'].map(v => v + ' [tipo] [cantidad] [@tag]')
  66. handler.tags = ['econ'];
  67. handler.command = ['payxp', 'transfer', 'darxp', 'dar', 'enviar', 'transferir']
  68. handler.disabled = false
  69. handler.register = true
  70. export default handler
  71. function special(type) {
  72. let b = type.toLowerCase()
  73. let special = (['common', 'uncoommon', 'mythic', 'legendary', 'pet'].includes(b) ? ' Crate' : '')
  74. return special
  75. }
  76. function isNumber(x) {
  77. return !isNaN(x)
  78. }