Demon0no
Demon0no
DIAdiscord.js - Imagine an app
Created by Demon0no on 10/12/2023 in #djs-questions
discord-api-types APIGuildMember no permissions bit field?
Shouldn't APIGuildMember ( https://discord-api-types.dev/api/discord-api-types-v10/interface/APIGuildMember ) include permissions, just like GuildMember ( https://discord.com/developers/docs/resources/guild#guild-member-object )? I'm using the "@discordjs/rest" and "discord-api-types" npm packages in my app (written in typescript) and am trying to check if a user has certain permissions, but the Type doesn't have the permission field. Also there's basicly no examples of how to use the "@discordjs/rest" package. The only examples are here and they only show post, not get! Simplified example of what I'm trying to do...
import { REST } from "@discordjs/rest";
import { Routes, type APIGuildMember } from "discord-api-types/v10";

const rest = new REST({ version: "10" }).setToken("Imagine I put a valid token here lol");

const member = await rest.get(Routes.guildMember("a valid guild id", "a valid user id"));
member.permissions // Property 'permissions' does not exist on type '{}'.ts(2339)
import { REST } from "@discordjs/rest";
import { Routes, type APIGuildMember } from "discord-api-types/v10";

const rest = new REST({ version: "10" }).setToken("Imagine I put a valid token here lol");

const member = await rest.get(Routes.guildMember("a valid guild id", "a valid user id"));
member.permissions // Property 'permissions' does not exist on type '{}'.ts(2339)
rest.get() returns a Promise<unknown>, so what am I gonna do with that in typescript? If I use as APIGuildMember | null technically typescript has no problem with it, but as soon as I'm trying to use the .permission typescript's gonna cry that APIGuildMember doesn't have the property permissions. So, am I using the rest.get() in an unsupported way, or am I just not supposed to do permission stuff with these libraries, or is APIGuildMember.permissions actually just missing accidentally and will be added?
2 replies