mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
no more any types, forgot to actually call env in migration
This commit is contained in:
@@ -9,8 +9,8 @@ migrate(app => {
|
|||||||
const password = process.env.PASSWORD ?? '1234567890'
|
const password = process.env.PASSWORD ?? '1234567890'
|
||||||
|
|
||||||
// This should be communicated to the user, or be set by the user.
|
// This should be communicated to the user, or be set by the user.
|
||||||
record.set("email", "test@example.com")
|
record.set("email", email)
|
||||||
record.set("password", "1234567890")
|
record.set("password", password)
|
||||||
|
|
||||||
app.save(record)
|
app.save(record)
|
||||||
const data = [
|
const data = [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { HelixUser } from "@twurple/api"
|
import { HelixUser } from "@twurple/api"
|
||||||
import pb from "./pocketbase"
|
import pb, { User } from "./pocketbase"
|
||||||
|
|
||||||
// const COOLDOWN = 1000 * 60 * 60 * 24 * 30 // 1000 milliseconds * 60 seconds * 60 minutes * 24 hours * 30 days
|
// const COOLDOWN = 1000 * 60 * 60 * 24 * 30 // 1000 milliseconds * 60 seconds * 60 minutes * 24 hours * 30 days
|
||||||
export const COOLDOWN = 1000 * 60 * 15
|
export const COOLDOWN = 1000 * 60 * 15
|
||||||
@@ -7,7 +7,7 @@ export const COOLDOWN = 1000 * 60 * 15
|
|||||||
interface lootboxReadyResult {
|
interface lootboxReadyResult {
|
||||||
result: boolean,
|
result: boolean,
|
||||||
lastlootbox: number,
|
lastlootbox: number,
|
||||||
DBuser: any // TODO: proper types for db user (again). check RecordModel
|
DBuser: User
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function lootboxReady(user: HelixUser | null): Promise<lootboxReadyResult> {
|
export async function lootboxReady(user: HelixUser | null): Promise<lootboxReadyResult> {
|
||||||
|
|||||||
@@ -1,4 +1,36 @@
|
|||||||
import PocketBase from 'pocketbase'
|
import PocketBase, { BaseModel, RecordService } from 'pocketbase'
|
||||||
|
import { inventory } from "./userHelper"
|
||||||
|
|
||||||
|
export interface User extends BaseModel {
|
||||||
|
twitchid: string,
|
||||||
|
firstname: string,
|
||||||
|
inventory: inventory,
|
||||||
|
itemuses: inventory,
|
||||||
|
balance: number,
|
||||||
|
lastlootbox: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TTVAuth extends BaseModel {
|
||||||
|
auth: JSON,
|
||||||
|
main: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Timeout extends BaseModel {
|
||||||
|
source: 'silverbullet' | 'grenade' | 'blaster' | 'tnt',
|
||||||
|
attacker: string,
|
||||||
|
target: string,
|
||||||
|
attackername: string,
|
||||||
|
targetname: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TypedPocketBase extends PocketBase {
|
||||||
|
collection(idOrName: string): RecordService,
|
||||||
|
collection(idOrName: 'users'): RecordService<User>,
|
||||||
|
collection(idOrName: 'ttvauth'): RecordService<TTVAuth>
|
||||||
|
collection(idOrName: 'timeouts'): RecordService<Timeout>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const PBURL = process.env.PBURL ?? 'http://pocketbase:8090'
|
const PBURL = process.env.PBURL ?? 'http://pocketbase:8090'
|
||||||
const pb = new PocketBase(PBURL)
|
const pb = new PocketBase(PBURL) as TypedPocketBase
|
||||||
export default pb
|
export default pb
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import pb from './pocketbase'
|
import pb, { User } from './pocketbase'
|
||||||
import { HelixUser } from '@twurple/api'
|
import { HelixUser } from '@twurple/api'
|
||||||
|
|
||||||
export const EMPTYINV: inventory = {
|
export const EMPTYINV: inventory = {
|
||||||
@@ -26,7 +26,7 @@ export async function getDBID(user: HelixUser) {
|
|||||||
|
|
||||||
type balanceGetResult = {
|
type balanceGetResult = {
|
||||||
balance: number,
|
balance: number,
|
||||||
data: any // TODO: propet type for data returned from database
|
data: User
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getBalance(user: HelixUser): Promise<balanceGetResult> {
|
export async function getBalance(user: HelixUser): Promise<balanceGetResult> {
|
||||||
|
|||||||
Reference in New Issue
Block a user