CampFirePlay/commands/property/propertySell.js
Degradin baa0b5f3a9 global refactoring
Все переведено в модули
2023-10-08 23:43:12 +03:00

102 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const {
weaponshop,
slots,
rarecars,
simplecars,
houses,
cars,
phones,
weapons,
equipment,
UserModel,
WorldModel,
JobModel,
PropertyModel,
BusinessModel,
ReportModel,
BlockModel,
PromocodeModel,
mainChat,
adminList,
expToUp,
topSym
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/config')
const {
spaces,
spacesWithMarkdown,
escape,
generatePromo,
generateVoucher,
getCurrentTime,
getSlot,
giveExp,
matPriceUpdate,
rand,
random,
setCooldown,
weaponShopUpdate,
stats
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/utils')
module.exports = async (ctx) => {
ctx.args = ctx.update.message.text.split(' ')
let user = await UserModel.findByPk(ctx.from.id)
let property = await PropertyModel.findByPk(ctx.from.id);
let world = await WorldModel.findByPk(1)
if (!ctx.args[1]) return ctx.reply(`Не указан аргумент.`)
if (ctx.args[1] == "house") {
if (!property.house.name) return await ctx.reply(`У вас нет дома.`)
let name = property.house.name
user.money += Math.round(property.house.price/2)
world.balance -= Math.round(property.house.price/2)
property.house = 0
await user.save()
await world.save()
await property.save()
return await ctx.reply(`Вы продали ${name}`)
}
if (ctx.args[1] == "car") {
if (!property.car.name) return await ctx.reply(`У вас нет автомобиля.`)
let name = property.car.name
user.money += Math.round(property.car.price/2)
world.balance -= Math.round(property.car.price/2)
property.car = 0
await user.save()
await world.save()
await property.save()
return await ctx.reply(`Вы продали ${name}`)
}
if (ctx.args[1] == "phone") {
if (!property.mobile.name) return await ctx.reply(`У вас нет телефона.`)
let name = property.mobile.name
user.money += Math.round(property.mobile.price/2)
world.balance -= Math.round(property.mobile.price/2)
property.mobile = 0
await user.save()
await world.save()
await property.save()
return await ctx.reply(`Вы продали ${name}`)
}
if (ctx.args[1] == "equipment") {
if (!property.equipment.name) return await ctx.reply(`У вас нет экипировки.`)
let name = property.equipment.name
user.money += Math.round(property.equipment.price/2)
world.balance -= Math.round(property.equipment.price/2)
property.equipment = 0
await user.save()
await world.save()
await property.save()
return await ctx.reply(`Вы продали ${name}`)
}
if (ctx.args[1] == "weapon") {
if (!property.weapon.name) return await ctx.reply(`У вас нет оружия.`)
let name = property.weapon.name
user.money += Math.round(property.weapon.price/2)
world.balance -= Math.round(property.weapon.price/2)
property.weapon = 0
await user.save()
await world.save()
await property.save()
return await ctx.reply(`Вы продали ${name}`)
}
}