|
|
|
@ -167,90 +167,6 @@ const command = {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "cf": {
|
|
|
|
|
if (
|
|
|
|
|
(isNaN(splitted[3]) && splitted[3] !== "all") ||
|
|
|
|
|
splitted[3] === 0
|
|
|
|
|
) {
|
|
|
|
|
await client.say(
|
|
|
|
|
msg.channelName,
|
|
|
|
|
`${msg.displayName}, arg needs to be a valid number or 'all'`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (splitted[3] !== "all") {
|
|
|
|
|
if (parseInt(splitted[3]) > user.megis.megis) {
|
|
|
|
|
await client.say(
|
|
|
|
|
msg.channelName,
|
|
|
|
|
`${msg.displayName}, you don't have that much megis!`
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const takeBet = await prisma.user.update({
|
|
|
|
|
where: {
|
|
|
|
|
userId: msg.senderUserID,
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
megis: {
|
|
|
|
|
update: {
|
|
|
|
|
megis: {
|
|
|
|
|
decrement:
|
|
|
|
|
splitted[3] === "all"
|
|
|
|
|
? parseInt(user.megis.megis)
|
|
|
|
|
: parseInt(splitted[3]),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
include: {
|
|
|
|
|
megis: true,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const flip = Math.floor(Math.random() * 2);
|
|
|
|
|
let result;
|
|
|
|
|
|
|
|
|
|
if (flip === 1) {
|
|
|
|
|
result = await prisma.user.update({
|
|
|
|
|
where: {
|
|
|
|
|
userId: msg.senderUserID,
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
megis: {
|
|
|
|
|
update: {
|
|
|
|
|
megis: {
|
|
|
|
|
increment:
|
|
|
|
|
splitted[3] === "all"
|
|
|
|
|
? user.megis.megis * 3
|
|
|
|
|
: splitted[3] * 3,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
include: {
|
|
|
|
|
megis: true,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await client.say(
|
|
|
|
|
msg.channelName,
|
|
|
|
|
result
|
|
|
|
|
? `${msg.displayName}, you won! +${
|
|
|
|
|
splitted[3] === "all" ? user.megis.megis * 2 : splitted[3] * 2
|
|
|
|
|
} Current megis: ${result.megis.megis}`
|
|
|
|
|
: `${msg.displayName}, you lost! -${
|
|
|
|
|
splitted[3] === "all" ? user.megis.megis : splitted[3]
|
|
|
|
|
} Current megis: ${takeBet.megis.megis}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "lb": {
|
|
|
|
|
const allMegisers = await prisma.user.findMany({
|
|
|
|
|
take: 3,
|
|
|
|
|