CampFirePlay/commands/carcantainers/chooseContainer.js
Degradin 906fffd2ca finaltotransfer
Подготовка к переезду на другой сервер
2024-05-04 19:59:35 +03:00

33 lines
1.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 {
rarecars,
simplecars,
UserModel,
PropertyModel
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/config')
const {
spaces
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/utils')
module.exports = async (ctx) => {
let data = ctx.update.callback_query.data;
let user = await UserModel.findByPk(ctx.from.id)
let property = await PropertyModel.findByPk(ctx.from.id)
if(user.money < 500000) return ctx.telegram.answerCbQuery(ctx.callbackQuery.id, `Открытие контейнера стоит ₽500.000`, {show_alert: true})
if(property.car1.name) return ctx.telegram.answerCbQuery(ctx.callbackQuery.id, `У вас уже есть автомобиль\nПродайте текущий автомобиль: /sell car`, {show_alert: true})
user.money -= 500000
let userWin = null
switch(data){
case `container_7`:
userWin = rarecars.random()
break;
default:
userWin = simplecars.random()
break;
}
property.car1 = userWin
property.car1.health = 100
user.save()
property.save()
ctx.deleteMessage()
return await ctx.sendPhoto(userWin.image, { caption: `В контейнере была: ${userWin.name} стоимостью ₽${spaces(userWin.price)}`})
}