The weeb for the next gen discord boat - Wamellow wamellow.com
bot discord
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

move api types & format api files

Luna 32614dcc 6e5f5f5f

+67 -55
+13 -37
app/ai-gallery/api.ts
··· 1 1 import { defaultFetchOptions } from "@/lib/api"; 2 - import { ApiError } from "@/typings"; 3 - 4 - export interface Upload { 5 - id: string; 6 - guildId?: string | null; 7 - authorId: string; 8 - 9 - prompt: string; 10 - negativePrompt?: string | null; 11 - model: string; 12 - 13 - verified: boolean; 14 - nsfw: boolean; 15 - 16 - createdAt: string; 17 - } 18 - 19 - interface Uploads { 20 - results: Upload[]; 21 - pagination: { 22 - total: number; 23 - pages: number; 24 - } 25 - } 2 + import { 3 + ApiError, 4 + ApiV1UploadGetResponse, 5 + ApiV1UploadsGetResponse 6 + } from "@/typings"; 26 7 27 8 export async function getUploads(options?: Partial<{ 28 9 model: string; 29 10 nsfw: boolean; 30 11 page: number; 31 12 query: string; 32 - }>): Promise<Uploads | ApiError> { 13 + }>): Promise<ApiV1UploadsGetResponse | ApiError> { 33 14 34 15 const params = new URLSearchParams(); 35 16 if (options?.model) params.append("model", options.model); ··· 37 18 if (options?.page) params.append("page", (options.page - 1).toString()); 38 19 if (options?.query) params.append("query", options.query); 39 20 40 - const res = await fetch(`${process.env.NEXT_PUBLIC_API}/ai?${params.toString()}`, 21 + const res = await fetch( 22 + `${process.env.NEXT_PUBLIC_API}/ai?${params.toString()}`, 41 23 defaultFetchOptions 42 24 ); 43 25 44 26 return res.json(); 45 27 } 46 28 47 - export interface ExtendedUpload extends Upload { 48 - author: { 49 - username: string; 50 - globalName: string; 51 - avatar: string | null; 52 - bot?: boolean; 53 - }; 54 - } 55 - 56 - export async function getUpload(uploadId: string): Promise<ExtendedUpload | ApiError> { 57 - const res = await fetch(`${process.env.NEXT_PUBLIC_API}/ai/${uploadId}`, defaultFetchOptions); 29 + export async function getUpload(uploadId: string): Promise<ApiV1UploadGetResponse | ApiError> { 30 + const res = await fetch( 31 + `${process.env.NEXT_PUBLIC_API}/ai/${uploadId}`, 32 + defaultFetchOptions 33 + ); 58 34 59 35 return res.json(); 60 36 }
+1 -1
app/dashboard/[guildId]/leaderboards/page.tsx
··· 122 122 ratio="aspect-[4/1]" 123 123 dataName="banner" 124 124 description="Enter a url which should be the banner of the leaderboard web page. The recomended image ration is 4:1 and recommended resolution 1024x256px." 125 - defaultState={data.banner || ""} 125 + defaultState={data.bannerUrl || ""} 126 126 /> 127 127 </div> 128 128
+16 -12
app/leaderboard/[guildId]/api.ts
··· 1 + import { defaultFetchOptions } from "@/lib/api"; 1 2 import { 2 3 ApiV1GuildsModulesLeaderboardGetResponse, 3 4 ApiV1GuildsTopmembersGetResponse, ··· 6 7 } from "@/typings"; 7 8 8 9 export async function getDesign(guildId: string): Promise<ApiV1GuildsModulesLeaderboardGetResponse | RouteErrorResponse | undefined> { 9 - const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/modules/leaderboard`, { 10 - headers: { Authorization: process.env.API_SECRET as string }, 11 - next: { revalidate: 60 * 60 } 12 - }); 10 + const res = await fetch( 11 + `${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/modules/leaderboard`, 12 + defaultFetchOptions 13 + ); 13 14 14 15 return res.json(); 15 16 } ··· 17 18 export async function getTopMembers(guildId: string, options: { page: number, type: string }): Promise<ApiV1GuildsTopmembersGetResponse[] | RouteErrorResponse | undefined> { 18 19 if (options.type !== "messages" && options.type !== "voiceminutes" && options.type !== "invites") return []; 19 20 20 - const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/top-members?type=${options.type}&page=${options.page - 1}`, { 21 - headers: { Authorization: process.env.API_SECRET as string }, 22 - next: { revalidate: 60 } 23 - }); 21 + const res = await fetch( 22 + `${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/top-members?type=${options.type}&page=${options.page - 1}`, 23 + { 24 + ...defaultFetchOptions, 25 + next: { revalidate: 60 } 26 + } 27 + ); 24 28 25 29 return res.json(); 26 30 } 27 31 28 32 export async function getPagination(guildId: string): Promise<ApiV1GuildsTopmembersPaginationGetResponse | RouteErrorResponse | undefined> { 29 - const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/top-members/pagination`, { 30 - headers: { Authorization: process.env.API_SECRET as string }, 31 - next: { revalidate: 60 * 60 } 32 - }); 33 + const res = await fetch( 34 + `${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/top-members/pagination`, 35 + defaultFetchOptions 36 + ); 33 37 34 38 return res.json(); 35 39 }
+1 -1
app/leaderboard/[guildId]/layout.tsx
··· 104 104 className="w-full object-cover" 105 105 classNames={{ img: "h-36 md:h-64", blurredImg: "h-40 md:h-72 -top-5" }} 106 106 isBlurred 107 - src={design && "banner" in design && design.banner ? design.banner : paintPic.src} 107 + src={design && "bannerUrl" in design && design.bannerUrl ? design.bannerUrl : paintPic.src} 108 108 width={3840 / 2} 109 109 height={2160 / 2} 110 110 />
+4 -1
lib/api.ts
··· 6 6 refetchOnMount: false 7 7 }; 8 8 9 - export const defaultFetchOptions = { headers: { Authorization: process.env.API_SECRET as string }, next: { revalidate: 60 * 60 } }; 9 + export const defaultFetchOptions = { 10 + headers: { Authorization: process.env.API_SECRET as string }, 11 + next: { revalidate: 60 * 60 } 12 + }; 10 13 11 14 export async function getData<T>(path: string, domain?: string) { 12 15 const response = await fetch(`${domain || process.env.NEXT_PUBLIC_API}${path}`, {
+32 -3
typings.ts
··· 19 19 id: string; 20 20 name: string; 21 21 icon: string | null; 22 - owner: boolean; 23 - permissions: string; 24 22 } 25 23 26 24 export interface RouteErrorResponse { ··· 216 214 } 217 215 218 216 export interface ApiV1GuildsModulesLeaderboardGetResponse { 219 - banner: string | null; 217 + bannerUrl: string | null; 220 218 221 219 backgroundColor: number | null; 222 220 textColor: number | null; ··· 338 336 whitelistRoleIds: string[]; 339 337 } 340 338 339 + export interface Upload { 340 + id: string; 341 + guildId?: string | null; 342 + authorId: string; 343 + 344 + prompt: string; 345 + negativePrompt?: string | null; 346 + model: string; 347 + 348 + verified: boolean; 349 + nsfw: boolean; 350 + 351 + createdAt: string; 352 + } 353 + 354 + export interface ApiV1UploadsGetResponse { 355 + results: Upload[]; 356 + pagination: { 357 + total: number; 358 + pages: number; 359 + } 360 + } 361 + 362 + export interface ApiV1UploadGetResponse extends Upload { 363 + author: { 364 + username: string; 365 + globalName: string; 366 + avatar: string | null; 367 + bot?: boolean; 368 + }; 369 + } 341 370 export interface PronounsResponse { 342 371 status: number; 343 372 content: string[];