-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGuild.ts
More file actions
42 lines (39 loc) · 947 Bytes
/
Guild.ts
File metadata and controls
42 lines (39 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Database from "../db"
import { Prisma, UserGuildData, FactoryReset, PremiumGuildSlot, Guild } from "../../../../node_modules/.prisma/client"
export async function getGuildData(
this: Database,
guildId: string,
include: Prisma.GuildInclude = { premiumGuildSlots: true }
): Promise<
Guild & {
userData?: UserGuildData[] | undefined
premiumGuildSlots?: PremiumGuildSlot[] | undefined
factoryResets?: FactoryReset[] | undefined
_count?: Prisma.GuildCountOutputType | undefined
}
> {
if (!guildId) throw new Error("No guild ID provided")
const guildData = await this.db.guild.upsert({
where: {
id: guildId,
},
update: {},
create: {
id: guildId,
},
include,
})
return guildData
}
export async function deleteAllGuildSettings(this: Database, guildId: string): Promise<void> {
await this.db.guild.delete({
where: {
id: guildId,
},
})
await this.db.guild.create({
data: {
id: guildId,
},
})
}