Zeke
Zeke
Explore posts from servers
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
Is there no solution lol?
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
enum GuildAuthStatus {
NotFound = 'Not Found',
Unauthorized = 'Unauthorized',
Authorized = 'Authorized',
}

export async function getGuild(guildId: string) {
const session = await auth();

const botGuildRes = await fetch(`https://discord.com/api/v10/guilds/${guildId}`, {
headers: {
Authorization: 'Bot ' + process.env.DISCORD_BOT_TOKEN,
},
next: { revalidate: 4 }
});

if (!botGuildRes.ok) {
const userGuild = await getUserGuild(guildId, session?.user.access_token)
delGuildDoc(guildId)

if (!userGuild || !userGuild.owner) {
return { status: GuildAuthStatus.Unauthorized, guild: userGuild }
}

return { status: GuildAuthStatus.NotFound, guild: userGuild };
};

const botGuild: APIGuild = await botGuildRes.json();
setupGuildDoc(botGuild);

if (botGuild.owner_id !== session?.user.id) {
return { status: GuildAuthStatus.Unauthorized, guild: botGuild };
};

return { status: GuildAuthStatus.Authorized, guild: botGuild };
};
enum GuildAuthStatus {
NotFound = 'Not Found',
Unauthorized = 'Unauthorized',
Authorized = 'Authorized',
}

export async function getGuild(guildId: string) {
const session = await auth();

const botGuildRes = await fetch(`https://discord.com/api/v10/guilds/${guildId}`, {
headers: {
Authorization: 'Bot ' + process.env.DISCORD_BOT_TOKEN,
},
next: { revalidate: 4 }
});

if (!botGuildRes.ok) {
const userGuild = await getUserGuild(guildId, session?.user.access_token)
delGuildDoc(guildId)

if (!userGuild || !userGuild.owner) {
return { status: GuildAuthStatus.Unauthorized, guild: userGuild }
}

return { status: GuildAuthStatus.NotFound, guild: userGuild };
};

const botGuild: APIGuild = await botGuildRes.json();
setupGuildDoc(botGuild);

if (botGuild.owner_id !== session?.user.id) {
return { status: GuildAuthStatus.Unauthorized, guild: botGuild };
};

return { status: GuildAuthStatus.Authorized, guild: botGuild };
};
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
Or, null, since it might not exist
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
Iā€™m on mobile, but The get guild function fetch request discord api for v10 guild, inline with what discord api types APIGuild should be
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
The jsx where guild.id is used is wrapped in a guild not null condition.
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
The relevant code:
import { auth } from "@/auth";
import { getGuild } from "@/lib/guilds";
import { PlusIcon, ExclamationTriangleIcon } from "@heroicons/react/24/outline";
import { APIGuild } from "discord-api-types/v10";
import { Options } from "../_components/Options";
import db from "@/lib/db";
import { GroupBasicResponse, GroupMembershipResponse } from "roblox-api-types";
import Block from "@/app/_components/Block";
import Image from "next/image";

export const runtime = "edge";

export default async function Page({ params }: { params: { id: string } }) {
const session = await auth();

const guildRes: { status: string; guild: APIGuild | null } = await getGuild(params.id);
const guild = guildRes.guild;

const guildContent = guild ? (
<>
{guild.icon ? (
<Image src={`https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}.png`} alt={`${guild.name} Icon`} className='h-16 w-16 rounded' width={100} height={100} />
) : (
<span className='h-16 w-16 flex items-center justify-center'>{guild.name.charAt(0)}</span>
)
}
<span className='text-lg'>{guild.name}</span>
</>
) : (
<>
<span className='h-16 w-16 flex items-center text-4xl justify-center'>N</span>
<span className='text-lg'>Not Found</span>
</>
);
import { auth } from "@/auth";
import { getGuild } from "@/lib/guilds";
import { PlusIcon, ExclamationTriangleIcon } from "@heroicons/react/24/outline";
import { APIGuild } from "discord-api-types/v10";
import { Options } from "../_components/Options";
import db from "@/lib/db";
import { GroupBasicResponse, GroupMembershipResponse } from "roblox-api-types";
import Block from "@/app/_components/Block";
import Image from "next/image";

export const runtime = "edge";

export default async function Page({ params }: { params: { id: string } }) {
const session = await auth();

const guildRes: { status: string; guild: APIGuild | null } = await getGuild(params.id);
const guild = guildRes.guild;

const guildContent = guild ? (
<>
{guild.icon ? (
<Image src={`https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}.png`} alt={`${guild.name} Icon`} className='h-16 w-16 rounded' width={100} height={100} />
) : (
<span className='h-16 w-16 flex items-center justify-center'>{guild.name.charAt(0)}</span>
)
}
<span className='text-lg'>{guild.name}</span>
</>
) : (
<>
<span className='h-16 w-16 flex items-center text-4xl justify-center'>N</span>
<span className='text-lg'>Not Found</span>
</>
);
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
My vercel output where the error occurs:
Type error: Property 'id' does not exist on type 'APIGuild'.
20 | <>
21 | {guild.icon ? (
> 22 | <Image src={`https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}.png`} alt={`${guild.name} Icon`} className='h-16 w-16 rounded' width={100} height={100} />
| ^
23 | ) : (
24 | <span className='h-16 w-16 flex items-center justify-center'>{guild.name.charAt(0)}</span>
25 | )
Error: Command "npm run build" exited with 1
Type error: Property 'id' does not exist on type 'APIGuild'.
20 | <>
21 | {guild.icon ? (
> 22 | <Image src={`https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}.png`} alt={`${guild.name} Icon`} className='h-16 w-16 rounded' width={100} height={100} />
| ^
23 | ) : (
24 | <span className='h-16 w-16 flex items-center justify-center'>{guild.name.charAt(0)}</span>
25 | )
Error: Command "npm run build" exited with 1
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
PS D:\rl-app> node -v
v21.6.1
PS D:\rl-app> node -v
v21.6.1
14 replies
DIAdiscord.js - Imagine a boo! šŸ‘»
Created by Zeke on 3/8/2024 in #djs-questions
Property 'id' does not exist on type 'APIGuild'.
PS D:\rl-app> npm list
ā”œā”€ā”€ @auth/[email protected]
ā”œā”€ā”€ @headlessui/[email protected]
ā”œā”€ā”€ @headlessui/[email protected]
ā”œā”€ā”€ @heroicons/[email protected]
ā”œā”€ā”€ @prisma/[email protected]
ā”œā”€ā”€ @prisma/[email protected]
ā”œā”€ā”€ @types/[email protected]
ā”œā”€ā”€ @types/[email protected]
ā”œā”€ā”€ @types/[email protected]
ā”œā”€ā”€ @vercel/[email protected]
ā”œā”€ā”€ @vercel/[email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā””ā”€ā”€ [email protected]
PS D:\rl-app> npm list
ā”œā”€ā”€ @auth/[email protected]
ā”œā”€ā”€ @headlessui/[email protected]
ā”œā”€ā”€ @headlessui/[email protected]
ā”œā”€ā”€ @heroicons/[email protected]
ā”œā”€ā”€ @prisma/[email protected]
ā”œā”€ā”€ @prisma/[email protected]
ā”œā”€ā”€ @types/[email protected]
ā”œā”€ā”€ @types/[email protected]
ā”œā”€ā”€ @types/[email protected]
ā”œā”€ā”€ @vercel/[email protected]
ā”œā”€ā”€ @vercel/[email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā”œā”€ā”€ [email protected]
ā””ā”€ā”€ [email protected]
14 replies