diff --git a/src/handbook/src/backend/data.ts b/src/handbook/src/backend/data.ts index e0526d0e6..159ba7d95 100644 --- a/src/handbook/src/backend/data.ts +++ b/src/handbook/src/backend/data.ts @@ -2,4 +2,32 @@ import avatars from "@data/avatars.json"; import commands from "@data/commands.json"; import items from "@data/items.csv"; -console.log(avatars, commands, items); +import type { Command, Avatar, Item } from "@backend/types"; + +/** + * Fetches and casts all commands in the file. + */ +export function getCommands(): { [key: string]: Command } { + return commands as { [key: string]: Command }; +} + +/** + * Fetches and casts all avatars in the file. + */ +export function getAvatars(): { [key: number]: Avatar } { + return avatars as { [key: number] : Avatar }; +} + +/** + * Fetches and casts all items in the file. + */ +export function getItems(): Item[] { + return items.map(item => { + return { + id: item[0], + name: item[1], + quality: item[2], + type: item[3] + }; + }); +} diff --git a/src/handbook/src/backend/types.ts b/src/handbook/src/backend/types.ts index b9aa97d28..d1be6ae03 100644 --- a/src/handbook/src/backend/types.ts +++ b/src/handbook/src/backend/types.ts @@ -1,5 +1,52 @@ export type Page = "Home" | "Commands"; +export type Command = { + name: string[]; + description: string; + usage: string[]; + permission: string[]; + target: Target; +}; + +export type Avatar = { + name: string; + quality: Quality; + id: number; +}; + +export type Item = { + id: number; + name: string; + quality: Quality; + type: ItemType; +} + +export enum Target { + None = "NONE", + Offline = "OFFLINE", + Player = "PLAYER", + Online = "ONLINE" +} + +export enum Quality { + Legendary = "LEGENDARY", + Epic = "EPIC", + Rare = "RARE", + Uncommon = "UNCOMMON", + Common = "COMMON", + Unknown = "UNKNOWN" +} + +export enum ItemType { + None = 0, + Virtual = 1, + Material = 2, + Reliquary = 3, + Weapon = 4, + Display = 5, + Furniture = 6 +} + /** * Checks if a string is a page. *