23 lines
700 B
TypeScript
23 lines
700 B
TypeScript
import { auth } from "@/auth";
|
|
import { redirect, notFound } from "next/navigation";
|
|
import { getUserGuilds } from "@/lib/discord";
|
|
import LevelingEditor from "@/components/LevelingEditor";
|
|
|
|
export default async function LevelingPage({ params }: { params: Promise<{ guildId: string }> }) {
|
|
const session = await auth();
|
|
const { guildId } = await params;
|
|
|
|
if (!session?.accessToken) {
|
|
redirect("/");
|
|
}
|
|
|
|
const guilds = await getUserGuilds(session.accessToken as string);
|
|
const currentGuild = guilds.find((g) => g.id === guildId);
|
|
|
|
if (!currentGuild || !currentGuild.botInGuild) {
|
|
notFound();
|
|
}
|
|
|
|
return <LevelingEditor guildId={currentGuild.id} />;
|
|
}
|