def __init__(self, client_id, client_secret, scope, redirect_uri, *, code, token): client = WebApplicationClient(client_id, token=token) if (not (code or token)) or (code and token): raise ValueError( "Either 'code' or 'token' parameter must be provided, but not both." ) elif token: if not isinstance(token, dict): raise TypeError( "Parameter 'token' must be an instance of dict with at least the 'access_token' key.'" ) if "access_token" not in token: raise ValueError( "Parameter 'token' requires 'access_token' key.") elif ( "token_type" not in token ): # this is not required for the discord class but for the parent class token["token_type"] = "Bearer" elif code: client.populate_code_attributes({"code": code}) self._discord_client_secret = client_secret self._cached_user = None self._cached_guilds = None self._cached_connections = None super().__init__( client_id=client_id, scope=scope, redirect_uri=redirect_uri, token=token, client=client, )