mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 17:24:14 +02:00
49 lines
861 B
TypeScript
49 lines
861 B
TypeScript
import { container } from '@sapphire/framework';
|
|
import type { Snowflake } from 'discord.js';
|
|
|
|
export async function daily(userId: Snowflake, amount: number) {
|
|
const balance = await container.database.user.update({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
data: {
|
|
Balance: {
|
|
upsert: {
|
|
update: {
|
|
balance: { increment: amount },
|
|
},
|
|
create: {
|
|
balance: amount,
|
|
},
|
|
},
|
|
},
|
|
Daily: {
|
|
create: {
|
|
amount,
|
|
},
|
|
},
|
|
},
|
|
include: {
|
|
Balance: true,
|
|
},
|
|
});
|
|
|
|
return balance;
|
|
}
|
|
|
|
export async function getLastDaily(userId: Snowflake) {
|
|
const time = await container.database.daily.findFirst({
|
|
where: {
|
|
userId,
|
|
},
|
|
orderBy: {
|
|
id: 'desc',
|
|
},
|
|
select: {
|
|
time: true,
|
|
},
|
|
});
|
|
|
|
return time;
|
|
}
|