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.

put `getGuild` to global api

Luna b89321b7 1ba04add

+44 -50
+1 -1
app/(home)/bot/pronouns/page.tsx
··· 1 + import { Chip } from "@nextui-org/react"; 1 2 import { Montserrat } from "next/font/google"; 2 3 import Image from "next/image"; 3 4 import Link from "next/link"; ··· 7 8 import DiscordMessage from "@/components/discord/message"; 8 9 import { ServerButton } from "@/components/server-button"; 9 10 import cn from "@/utils/cn"; 10 - import { Chip } from "@nextui-org/react"; 11 11 12 12 const montserrat = Montserrat({ subsets: ["latin"] }); 13 13
+2 -2
app/(home)/privacy/page.tsx
··· 22 22 description, 23 23 type: "website", 24 24 url, 25 - images: `${getBaseUrl()}/pronouns-bot.webp` 25 + images: `${getBaseUrl()}/waya-v3.jpg` 26 26 }, 27 27 twitter: { 28 28 card: "summary", 29 29 site: "wamellow.com", 30 30 title, 31 31 description, 32 - images: `${getBaseUrl()}/pronouns-bot.webp` 32 + images: `${getBaseUrl()}/waya-v3.jpg` 33 33 } 34 34 }; 35 35 };
+1 -1
app/dashboard/[guildId]/greeting/passport/page.tsx
··· 10 10 import SelectInput from "@/components/inputs/SelectMenu"; 11 11 import Switch from "@/components/inputs/Switch"; 12 12 import Modal from "@/components/modal"; 13 + import Notice from "@/components/notice"; 13 14 import OverviewLinkComponent from "@/components/OverviewLinkComponent"; 14 15 import { ApiV1GuildsModulesPassportGetResponse, RouteErrorResponse } from "@/typings"; 15 16 import { getCanonicalUrl } from "@/utils/urls"; 16 - import Notice from "@/components/notice"; 17 17 18 18 export default function Home() { 19 19 const guild = guildStore((g) => g);
+4 -17
app/leaderboard/[guildId]/api.ts
··· 1 - import { ApiV1GuildsGetResponse, ApiV1GuildsModulesLeaderboardGetResponse, ApiV1GuildsTopmembersGetResponse, ApiV1GuildsTopmembersPaginationGetResponse } from "@/typings"; 2 - 3 - export async function getGuild(guildId: string): Promise<ApiV1GuildsGetResponse | undefined> { 4 - const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}`, { 5 - headers: { Authorization: process.env.API_SECRET as string }, 6 - next: { revalidate: 60 * 60 } 7 - }); 8 - 9 - const guild = await res.json(); 10 - return guild; 11 - } 1 + import { ApiV1GuildsModulesLeaderboardGetResponse, ApiV1GuildsTopmembersGetResponse, ApiV1GuildsTopmembersPaginationGetResponse } from "@/typings"; 12 2 13 3 export async function getDesign(guildId: string): Promise<ApiV1GuildsModulesLeaderboardGetResponse> { 14 4 const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/modules/leaderboard`, { ··· 16 6 next: { revalidate: 60 * 60 } 17 7 }); 18 8 19 - const design = await res.json(); 20 - return design; 9 + return res.json(); 21 10 } 22 11 23 12 export async function getTopMembers(guildId: string, options: { page: number, type: string }): Promise<ApiV1GuildsTopmembersGetResponse[]> { ··· 28 17 next: { revalidate: 60 } 29 18 }); 30 19 31 - const members = await res.json(); 32 - return members; 20 + return res.json(); 33 21 } 34 22 35 23 export async function getPagination(guildId: string): Promise<ApiV1GuildsTopmembersPaginationGetResponse> { ··· 38 26 next: { revalidate: 60 * 60 } 39 27 }); 40 28 41 - const pagination = await res.json(); 42 - return pagination; 29 + return res.json(); 43 30 }
+5 -4
app/leaderboard/[guildId]/layout.tsx
··· 5 5 6 6 import ImageReduceMotion from "@/components/image-reduce-motion"; 7 7 import { ListTab } from "@/components/list"; 8 + import { getGuild } from "@/lib/api"; 8 9 import paintPic from "@/public/paint.webp"; 9 10 import decimalToRgb from "@/utils/decimalToRgb"; 10 11 import { getCanonicalUrl } from "@/utils/urls"; 11 12 12 - import { getDesign, getGuild, getPagination } from "./api"; 13 + import { getDesign, getPagination } from "./api"; 13 14 import Side from "./side.component"; 14 15 15 - export interface LeaderboardProps { 16 + export interface Props { 16 17 params: { guildId: string }; 17 18 children: React.ReactNode; 18 19 } ··· 21 22 22 23 export const generateMetadata = async ({ 23 24 params 24 - }: LeaderboardProps): Promise<Metadata> => { 25 + }: Props): Promise<Metadata> => { 25 26 const guild = await getGuild(params.guildId); 26 27 27 28 const title = `${guild?.name || "Unknown"}'s Leaderboard`; ··· 61 62 export default async function RootLayout({ 62 63 params, 63 64 children 64 - }: LeaderboardProps) { 65 + }: Props) { 65 66 66 67 const guildPromise = getGuild(params.guildId); 67 68 const designPromise = getDesign(params.guildId);
+4 -3
app/leaderboard/[guildId]/open-graph.png/route.tsx
··· 4 4 import { ImageResponse } from "next/og"; 5 5 import { NextRequest } from "next/server"; 6 6 7 + import { getGuild } from "@/lib/api"; 7 8 import { truncate } from "@/utils/truncate"; 8 9 9 - import { getGuild, getTopMembers } from "../api"; 10 + import { getTopMembers } from "../api"; 10 11 import Icon from "../icon.component"; 11 - import { LeaderboardProps } from "../layout"; 12 + import { Props } from "../layout"; 12 13 13 14 export const revalidate = 3600; // 1 hour 14 15 15 16 export async function GET( 16 17 request: NextRequest, 17 - { params }: LeaderboardProps 18 + { params }: Props 18 19 ) { 19 20 let type = request.nextUrl.searchParams.get("type"); 20 21 if (type !== "messages" && type !== "voiceminutes" && type !== "invites") type = "messages";
+4 -3
app/leaderboard/[guildId]/page.tsx
··· 5 5 6 6 import ImageReduceMotion from "@/components/image-reduce-motion"; 7 7 import { AddButton, HomeButton, ScreenMessage, SupportButton } from "@/components/screen-message"; 8 + import { getGuild } from "@/lib/api"; 8 9 import SadWumpusPic from "@/public/sad-wumpus.gif"; 9 10 10 - import { getDesign, getGuild, getPagination, getTopMembers } from "./api"; 11 + import { getDesign, getPagination, getTopMembers } from "./api"; 11 12 import Icon from "./icon.component"; 12 13 import Pagination from "./pagination.component"; 13 14 14 - interface LeaderboardProps { 15 + interface Props { 15 16 params: { guildId: string }; 16 17 searchParams: { page: string, type: "messages" | "voiceminutes" | "invites" }; 17 18 } 18 19 19 20 export const revalidate = 60 * 60; 20 21 21 - export default async function Home({ params, searchParams }: LeaderboardProps) { 22 + export default async function Home({ params, searchParams }: Props) { 22 23 if (searchParams) searchParams.type ||= "messages"; 23 24 24 25 const guildPromise = getGuild(params.guildId);
+1 -11
app/passport/[guildId]/api.ts
··· 1 - import { ApiV1GuildsGetResponse, ApiV1GuildsModulesPassportGetResponse } from "@/typings"; 2 - 3 - export async function getGuild(guildId: string): Promise<ApiV1GuildsGetResponse> { 4 - const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}`, { 5 - headers: { Authorization: process.env.API_SECRET as string }, 6 - next: { revalidate: 60 * 60 } 7 - }); 8 - 9 - const guild = await res.json(); 10 - return guild; 11 - } 1 + import { ApiV1GuildsModulesPassportGetResponse } from "@/typings"; 12 2 13 3 export async function getPassport(guildId: string): Promise<ApiV1GuildsModulesPassportGetResponse> { 14 4 const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}/passport-verification`, {
+9 -8
app/passport/[guildId]/page.tsx
··· 9 9 import Notice, { NoticeType } from "@/components/notice"; 10 10 import OverviewLinkComponent from "@/components/OverviewLinkComponent"; 11 11 import { ServerButton } from "@/components/server-button"; 12 + import { getGuild } from "@/lib/api"; 12 13 import paintPic from "@/public/paint.webp"; 13 14 import decimalToRgb from "@/utils/decimalToRgb"; 14 15 import { getCanonicalUrl } from "@/utils/urls"; 15 16 16 - import { getGuild, getPassport } from "./api"; 17 + import { getPassport } from "./api"; 17 18 import Verify from "./verify.component"; 18 19 19 20 interface PassportProps { params: { guildId: string }, searchParams: { page: string, type: string } } ··· 23 24 }: PassportProps): Promise<Metadata> => { 24 25 const guild = await getGuild(params.guildId); 25 26 26 - const title = `Verify in ${guild.name}`; 27 - const description = `Easily verify yourself in ${guild.name} with a simple and safe captcha in the web to gain access all channels.`; 27 + const title = `Verify in ${guild?.name}`; 28 + const description = `Easily verify yourself in ${guild?.name} with a simple and safe captcha in the web to gain access all channels.`; 28 29 const url = getCanonicalUrl("passport", params.guildId); 29 30 30 31 return { ··· 74 75 <Notice type={NoticeType.Error} message={(passport as Record<string, string>).message} /> 75 76 } 76 77 77 - {guild.id === "1125063180801036329" && 78 + {guild?.id === "1125063180801036329" && 78 79 <Notice type={NoticeType.Info} message="This is a demo server to test out passport verification." > 79 80 <ServerButton 80 81 as={Link} ··· 95 96 <Image 96 97 alt="" 97 98 className="w-full object-cover h-[216px]" 98 - src={guild.banner ? `https://cdn.discordapp.com/banners/${guild?.id}/${guild?.banner}?size=512` : paintPic.src} 99 + src={guild?.banner ? `https://cdn.discordapp.com/banners/${guild?.id}/${guild?.banner}?size=512` : paintPic.src} 99 100 width={3840 / 10} 100 101 height={2160 / 10} 101 102 /> ··· 109 110 <div className="text-2xl dark:text-neutral-200 text-neutral-800 font-medium">{guild?.name || "Unknown Server"}</div> 110 111 <div className="text-sm font-semibold flex items-center gap-1"> 111 112 <HiUsers /> {intl.format(guild?.memberCount || 0)} 112 - <Image src="https://cdn.discordapp.com/emojis/875797879401361408.webp" width={18} height={18} alt="boost icon" className="ml-2" /> Level {guild.premiumTier} 113 + <Image src="https://cdn.discordapp.com/emojis/875797879401361408.webp" width={18} height={18} alt="boost icon" className="ml-2" /> Level {guild?.premiumTier} 113 114 </div> 114 115 </div> 115 116 </div> ··· 120 121 <ul> 121 122 {[ 122 123 "Secure server", 123 - `${intl.format(guild.memberCount)} members` 124 + `${intl.format(guild?.memberCount || 0)} members` 124 125 ].map((name) => ( 125 126 <li key={name} className="flex gap-1 items-center"> 126 127 <HiCheck className="text-violet-400" /> ··· 133 134 </li> 134 135 </ul> 135 136 136 - {typeof passport !== "object" && 137 + {guild && typeof passport !== "object" && 137 138 <Verify guild={guild} /> 138 139 } 139 140
+13
lib/api.ts
··· 1 + import { ApiV1GuildsGetResponse } from "@/typings"; 2 + 1 3 export const cacheOptions = { 2 4 cacheTime: 1000 * 60 * 5, 3 5 refetchOnWindowFocus: false, ··· 12 14 }); 13 15 14 16 return response.json() as Promise<T>; 17 + } 18 + 19 + export async function getGuild(guildId?: string | null): Promise<ApiV1GuildsGetResponse | undefined> { 20 + if (!guildId) return; 21 + 22 + const res = await fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guildId}`, { 23 + headers: { Authorization: process.env.API_SECRET as string }, 24 + next: { revalidate: 60 * 60 } 25 + }); 26 + 27 + return res.json(); 15 28 }