Finalizing the work for moving to TypeORM before testing of previously working functions begins

This commit is contained in:
2025-11-18 16:31:02 -05:00
parent 68d8415a77
commit 7d8e252b79
16 changed files with 82 additions and 261 deletions

View File

@@ -1,20 +1,21 @@
import { Guild, VoiceBasedChannel } from "discord.js";
import { SQLCommon } from "../storage/interfaces";
import { VoiceBasedChannel } from "discord.js";
import { IsNull, Repository } from "typeorm";
import { DBCall } from "../storage/entities/DBCall";
export async function breadbotInCall(db: SQLCommon, channel: VoiceBasedChannel) : Promise<boolean> {
const queryResult: Object[] = await db.getAllParameterized(
"SELECT * FROM calls WHERE channel_snowflake = ? AND call_end_time IS NULL",
[channel.id]
)
return queryResult.length != 0
export async function breadbotInCall(db: Repository<DBCall>, channel: VoiceBasedChannel) : Promise<boolean> {
return (await db.findOne({
where: {
channel: {channel_snowflake: channel.id},
call_end_time: IsNull()
}
})) != null
}
export async function getExistingCallID(db: SQLCommon, channel: VoiceBasedChannel) : Promise<Number> {
const queryResult: any[] = await db.getAllParameterized(
"SELECT * FROM calls WHERE channel_snowflake = ? AND call_end_time IS NULL",
[channel.id]
)
return queryResult.length != 0 ? queryResult[0].call_id : -1
export async function getExistingCallID(db: Repository<DBCall>, channel: VoiceBasedChannel) : Promise<Number | undefined> {
return (await db.findOne({
where: {
channel: {channel_snowflake: channel.id},
call_end_time: IsNull()
}
}))?.call_id
}