Is there a reason the discord-api-types package does not contain any of the optional values returned by the Discord API? I am trying to use permissions off a guild member, but my typescript is throwing a fit because the package does not include permissions on the type. Discord documentation has permissions as optional.
#Member Guild Permissions via API
33 messages · Page 1 of 1 (latest)
- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
this is a discordjs maintained package so im hoping some people are versed on it
Show your code where you have that issue. Or at least state what type you refer to
discord's official documentation has permissions as optional
mostly curious why the discord-api-types package has absolutely no optional values in it
returned when in the interaction object
And there’s a subtype of APIGuildMember for that
And that last statement lacks any proof. All optional properties are present in the types. In places where they actually are returned from the API
didnt see the subtype
makes more sense now that I look at how it's split up
well now im curious as to how I'm supposed to get a member's overall permissions via api
In what case do you need to do that?
administrator, manage server, etc.
essentially trying to check if a user can make certain changes to the server itself
No, I don’t mean what permissions. I mean what’s the use case?
In context of a bot?
in the sense that I need to limit a user's access to certain features if they aren't an administrator
and from outside of a bot, just using the bot's credentials
Then it‘s from a bot context. But how does that user authenticate who they are? OAuth2?
it's for a website independent of the bot
user logs in with oauth, site pulls certain guild details through the bot's credentials, then needs to determine what the user has access to
the site then makes configuration changes
everything works aside from figuring out what guild-level permissions the user has
If they login with OAuth2 then use that to get the guild and member information of that user. Not the bot credentials
I still need to be able to pull it through the id, not solely oauth
Why? Who needs to do that pull if they aren’t authenticated via OAuth2?
Member Guild Permissions via API
the server
Then it would have to fetch the roles and calculate the permissions by hierarchy from that. Or have an API on your bot process your website can query for that since the bot process has that information cached already
I was doing that before and wanted to avoid relying on the bot being online, but I'll look into the role stuff
Well, I still don’t understand when the server needs to fetch that information without a user actually being logged in and using the website
I've got a way to mimic a user for debugging, but that only works when the server doesn't need oauth
everything is id based rather than oauth
That sounds like a security issue in itself. As in someone might easily find a way to act as someone with another id although their OAuth2 doesn’t match
server validates it off the actual logged in user
it mimics certain access, not the entire site