mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Formatted code and clean up
This commit is contained in:
+13
-20
@@ -1,30 +1,27 @@
|
||||
import { Guild } from "@prisma/client";
|
||||
import { Snowflake } from "discord-api-types/v10";
|
||||
import Prisma from "./Prisma";
|
||||
import { Guild } from '@prisma/client';
|
||||
import { Snowflake } from 'discord-api-types/v10';
|
||||
import Prisma from './Prisma';
|
||||
|
||||
class Cache {
|
||||
|
||||
private cache: any;
|
||||
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.cache = {
|
||||
Guilds: {
|
||||
|
||||
}
|
||||
Guilds: {}
|
||||
};
|
||||
}
|
||||
|
||||
public async updateGuildsCache() {
|
||||
const Guilds = await Prisma.client.guild.findMany();
|
||||
for(let Guild of Guilds) {
|
||||
for (let Guild of Guilds) {
|
||||
this.setGuildData(Guild.id, Guild);
|
||||
}
|
||||
}
|
||||
|
||||
public async updateGuildCache(guildID: Snowflake) {
|
||||
const DBGuild = await Prisma.client.guild.findFirst({ where:{id: guildID} });
|
||||
|
||||
if(DBGuild === null) return;
|
||||
const DBGuild = await Prisma.client.guild.findFirst({ where: { id: guildID } });
|
||||
|
||||
if (DBGuild === null) return;
|
||||
this.setGuildData(guildID, DBGuild);
|
||||
}
|
||||
|
||||
@@ -32,9 +29,8 @@ class Cache {
|
||||
this.cache.Guilds[id] = data;
|
||||
}
|
||||
|
||||
public async getGuild(id: string): Promise<(Guild | undefined)> {
|
||||
if(typeof this.cache.Guilds[id] !== 'undefined')
|
||||
return this.cache.Guilds[id];
|
||||
public async getGuild(id: string): Promise<Guild | undefined> {
|
||||
if (typeof this.cache.Guilds[id] !== 'undefined') return this.cache.Guilds[id];
|
||||
|
||||
const Guild = await Prisma.client.guild.findFirst({
|
||||
where: {
|
||||
@@ -42,18 +38,15 @@ class Cache {
|
||||
}
|
||||
});
|
||||
|
||||
if(Guild === null)
|
||||
return undefined;
|
||||
if (Guild === null) return undefined;
|
||||
|
||||
this.setGuildData(Guild.id, Guild);
|
||||
return this.cache.Guilds[id];
|
||||
|
||||
}
|
||||
|
||||
public getGuilds(): void {
|
||||
return this.cache.Guilds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new Cache();
|
||||
export default new Cache();
|
||||
|
||||
Reference in New Issue
Block a user