Skip to content

Commit

Permalink
feat: added daily, weekly and monthly
Browse files Browse the repository at this point in the history
  • Loading branch information
kk committed Nov 8, 2023
1 parent 8fa56e9 commit f630a78
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/util/SeraphCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ export class SeraphCache {
return data.success && status == 200 ? (data.player as Components.Schemas.Player) : null;
};

public getCachedPlayer = async (uuid: string, mode: "daily" | "weekly" | "monthly") => {
let checkedUuid;
if (uuid.length == 32 || uuid.length == 36) {
checkedUuid = uuid;
} else {
const res = await this.getPlayerByName(uuid);
if (res == null) return null;
checkedUuid = res;
}

const { data, status } = await axios.get(`https://cache.seraph.si/seraph/${mode}/${checkedUuid}`, { headers: { ...this.headers } });
return data.success && status == 200 ? (data.data as Components.Schemas.Player) : null;
};

public getGuildByPlayer = async (uuid: string) => {
const { data, status } = await axios.get(`https://cache.seraph.si/guild/player/${uuid}`, { headers: { ...this.headers } });
if (data.success && status == 200) {
Expand Down

0 comments on commit f630a78

Please sign in to comment.