Finalizing the work for moving to TypeORM before testing of previously working functions begins
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user