feat: update api

This commit is contained in:
Twig 2025-07-10 22:51:14 +02:00
parent 15e5a21277
commit 59000709fe
No known key found for this signature in database

View file

@ -1,4 +1,4 @@
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse, StatsResponse } from "~/types/interfaces";
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse, StatsResponse, UserResponse } from "~/types/interfaces";
export const useApi = () => {
async function fetchGuilds(): Promise<GuildResponse[] | undefined> {
@ -33,6 +33,10 @@ export const useApi = () => {
return await fetchWithApi(`/users/${userId}`);
}
async function fetchFriends(): Promise<UserResponse[] | undefined> {
return await fetchWithApi('/me/friends')
}
async function fetchMessages(channelId: string, options?: { amount?: number, offset?: number }): Promise<MessageResponse[] | undefined> {
return await fetchWithApi(`/channels/${channelId}/messages`, { query: { amount: options?.amount ?? 100, offset: options?.offset ?? 0 } });
}
@ -59,6 +63,7 @@ export const useApi = () => {
fetchMember,
fetchUsers,
fetchUser,
fetchFriends,
fetchMessages,
fetchMessage,
fetchInstanceStats,