"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { Button } from "@/components/ui/button"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { setCustomization } from "@/lib/api"; import { useEffect } from "react"; import ColorProvider from "../ColorProvider"; import toast from "react-hot-toast"; const FormSchema = z.object({ website: z .string() .min(2, { message: "ID must be at least 2 characters.", }) .url({ message: "Image must be in URL form." }), }); export function BannerPopover({ server, get }: { server: string; get: any }) { const form = useForm>({ resolver: zodResolver(FormSchema), defaultValues: { website: "", }, }); async function onSubmit(data: z.infer) { if (data.website.startsWith("https://i.imgur.com")) { let imageId = data.website.split(".com")[1]; imageId = imageId.substring(1); toast.promise(setCustomization(server, { banner: imageId }), { loading: "Setting banner..", success: "Set banner!", error: "Error while setting banner", }); } else { toast.error( "To avoid view loggers, the Image URL must be from Imgur. (do not use the generic imgur.com URL, copy the direct image URL with i.imgur.com) " ); } } useEffect(() => console.log(get.discord), [get]); return (
Make sure the image is from Imgur, and the image format is png or gif.

Tutorial:

( Image URL )} />
); }