jillo-bot/src/lib/db.ts

89 lines
1.7 KiB
TypeScript

import knex from 'knex';
import * as log from './log';
export const db = knex({
client: 'sqlite3',
connection: {
filename: './jillo.sqlite'
},
useNullAsDefault: true,
log: {
warn: log.warn,
error: log.error,
deprecate: log.warn,
debug: log.info
}
});
export interface ScheduledSubscription {
name: string;
next: number;
}
export interface Subscription {
key: string,
channel: string,
guild?: string
}
export interface Counter {
id: number,
key: string,
emoji: string,
value: number,
channel: string,
guild: string,
message?: string,
allowlistConsumer: boolean,
allowlistProducer: boolean,
linkedItem?: number
}
export interface CounterUserLink {
id: number,
user: string,
producer: boolean
}
export interface CounterConfiguration {
id: number,
configName: string,
value: string
}
export interface CustomItem {
id: number,
guild: string,
name: string,
description?: string,
emoji: string,
type: 'plain' | 'weapon' | 'consumable',
// also damage for weapons; weapons are always unstackable (cus i said so)
maxStack: number,
behavior?: string,
untradable: boolean,
behaviorValue?: number
}
export interface ItemInventory {
user: string,
item: number,
quantity: number
}
export interface CraftingStationCooldown {
station: string,
user: string,
usedAt: number
}
export interface CustomCraftingRecipe {
id: number,
guild: string,
station: string
}
export interface CustomCraftingRecipeItem {
id: number,
item: number,
quantity: number,
type: 'input' | 'output' | 'requirement'
}
export interface Session {
id: string,
tokenType: string,
accessToken: string,
refreshToken: string,
expiresAt: number,
}