forked from syntaxbullet/AuroraBot-discord
Added Pay and Daily
This commit is contained in:
@@ -9,4 +9,10 @@ export async function getUserBalance(userId: string) {
|
||||
|
||||
export async function setUserBalance(userId: string, balance: number) {
|
||||
await DrizzleClient.update(users).set({ balance }).where(eq(users.userId, userId));
|
||||
}
|
||||
|
||||
export async function addUserBalance(userId: string, amount: number) {
|
||||
const user = await DrizzleClient.query.users.findFirst({ where: eq(users.userId, userId) });
|
||||
if (!user) return;
|
||||
await DrizzleClient.update(users).set({ balance: user.balance + amount }).where(eq(users.userId, userId));
|
||||
}
|
||||
@@ -8,4 +8,8 @@ export async function getUserById(userId: string) {
|
||||
|
||||
export async function createUser(userId: string) {
|
||||
return (await DrizzleClient.insert(users).values({ userId }).returning())[0]!;
|
||||
}
|
||||
|
||||
export async function updateUserDaily(userId: string, lastDaily: Date, dailyStreak: number) {
|
||||
await DrizzleClient.update(users).set({ lastDaily, dailyStreak }).where(eq(users.userId, userId));
|
||||
}
|
||||
Reference in New Issue
Block a user