wohali / oauth2-discord-new

New Discord Provider for the OAuth 2.0 Client
MIT License
118 stars 22 forks source link

Guilds #10

Closed StrangerGithuber closed 5 years ago

StrangerGithuber commented 5 years ago

Hello I am new in this and I am curious how can I get the guilds where the member is in? I need the guild id, name and owner. If I can't get the owner of the servers then how can I get the guild ID and guild name? Another question is if there is a function where I can retrieve if the member has a server and which one? Thank you in advance the answers. 👍

StrangerGithuber commented 5 years ago

Ehh solved. I only need send the member ID to the bot and then I will get the servers.

wohali commented 5 years ago

Glad you worked it out on your own!

oliverschloebe commented 5 years ago

@StrangerGithuber Care to share your solution? I can't figure out how to access the authenticated user's guilds after logging in. 🤔 Thank you!

HayateLaTech commented 5 years ago

@OliverSchloebe Heya, it's a bit tricky but you can retrieve the guilds with just using this library here - although not documented at all, maybe i'll PR a change to the readme for it if i got enough time

In order to get the guilds you need to create a new request to the endpoint for the guilds, remember to set your scopes accordingly so you surely have access to that endpoint ;D

` $guildsRequest = $provider->getAuthenticatedRequest('GET', $provider->getResourceOwnerDetailsUrl($token) . '/guilds', $token);

$guilds = $provider->getParsedResponse($guildsRequest);

var_dump($guilds); `

For information on every endpoint available please visit https://discordapp.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes

Cheers!