Closed itschasa closed 2 years ago
Hey! Thank you for the PR. It is a good solution for a general case as the most popular format of invites is covered by this. But discord invites can be in many different forms I think. Best solution would be to accept all forms that Discord accepts. If we do an x-context-properties request with any link that the Discord Client accepts, it returns the invite code in the response for the server we wish to join (This is one of the uses of the x-context-properties request except the header).
If it's a link tho, then you can't use it to join servers, it needs striping of its link. Also, X-Content-Properties (last time i checked) only uses the guild ID, channel ID and it's type, which can all be fetched from a GET request, which only uses the code part of the invite. You can see this on the client, and also when you visit invite links online.
lol
This is what I mean -> 1) You can put any link here (not just the code)
2) Discord does the x-context-properties request with whatever input you put in
3) It resolves the invite link into an invite code
4) invite code is used to join the server
^ This way users will be able to input ANY link discord supports as an invite, not just discord.gg/code
in the first image, you can just put a code. therefore it's compatible. but i just thought that it would be useful to automatically remove the link, as if the input is a url, it won't work.
I say this because Discord invites don't come only in discord.gg/code format you can put any of these and discord still accepts it discord.com/invite/code discord.com/api/v9/invite/code (And older APIs) discord.gg/api/v9/invite/code (And older APIs) discord.com/room discord.com/api/v9/invites/room (And older APIs)
By the method I described, we won't have to hard code all these, they'll be handled by discord on it's own. Even if it's not an actual link, discord sometimes accepts it, so it's best to leave on them what they accept and what they don't Even fake stuff like this ->
We either support everything discord client supports or we just support the code to skip the x-context-properties request
fair enough, may as well just close this lol
If you want, most of the code for it is already written, you would just have to return the code from the x-context-properties request, make it return an error if it had any problems getting the x-context-properties and using the invite code to join server to make it compatible with what I'm trying to say.
I don't think it really needs explaining, fixes issues like: #570