Skip to content

How to correctly use get a user's guilds? #3

Answered by nwunderly
chrisdewa asked this question in Q&A
Discussion options

You must be logged in to vote

client.login() is just a "one-shot" shortcut for the session.identify() method with internal session handling, after which it kills the session:

    async def login(self, code):
        """Shorthand for session setup + identify()"""
        async with self.session(code) as session:
            user = await session.identify()
        return user

Since a code can only be used once, the new session's attempt to get the user's guilds with the same code will throw that error. In order to make multiple API requests, you're going to want to use identify() within your async with context manager, the same way you're using session.guilds() now. Perhaps something like this:

@app.get('/callback')
async 

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@chrisdewa
Comment options

@nwunderly
Comment options

@chrisdewa
Comment options

@chrisdewa
Comment options

Answer selected by chrisdewa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants