diff --git a/lib/src/client.dart b/lib/src/client.dart index 1ef0af8e..a3c138f1 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -86,12 +86,12 @@ abstract class Nyxx { /// Create an instance of [NyxxRest] using the provided options. static Future connectRestWithOptions(RestApiOptions apiOptions, [RestClientOptions clientOptions = const RestClientOptions()]) async { - clientOptions.logger - ..info('Connecting to the REST API') - ..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}') - ..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}'); - return _doConnect(apiOptions, clientOptions, () async { + clientOptions.logger + ..info('Connecting to the REST API') + ..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}') + ..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}'); + final client = NyxxRest._(apiOptions, clientOptions); return client @@ -111,12 +111,12 @@ abstract class Nyxx { /// /// Note that `client.user.id` will contain [Snowflake.zero] if there no `identify` scope. static Future connectOAuth2WithOptions(OAuth2ApiOptions apiOptions, [RestClientOptions clientOptions = const RestClientOptions()]) async { - clientOptions.logger - ..info('Connecting to the REST API via OAuth2') - ..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}') - ..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}'); - return _doConnect(apiOptions, clientOptions, () async { + clientOptions.logger + ..info('Connecting to the REST API via OAuth2') + ..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}') + ..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}'); + final client = NyxxOAuth2._(apiOptions, clientOptions); final information = await client.users.fetchCurrentOAuth2Information(); @@ -136,16 +136,16 @@ abstract class Nyxx { GatewayApiOptions apiOptions, [ GatewayClientOptions clientOptions = const GatewayClientOptions(), ]) async { - clientOptions.logger - ..info('Connecting to the Gateway API') - ..fine( - 'Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent},' - ' Intents: ${apiOptions.intents.value}, Payloads: ${apiOptions.payloadFormat.value}, Compression: ${apiOptions.compression.name},' - ' Shards: ${apiOptions.shards?.join(', ')}, Total shards: ${apiOptions.totalShards}, Large threshold: ${apiOptions.largeThreshold}', - ) - ..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}'); - return _doConnect(apiOptions, clientOptions, () async { + clientOptions.logger + ..info('Connecting to the Gateway API') + ..fine( + 'Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent},' + ' Intents: ${apiOptions.intents.value}, Payloads: ${apiOptions.payloadFormat.value}, Compression: ${apiOptions.compression.name},' + ' Shards: ${apiOptions.shards?.join(', ')}, Total shards: ${apiOptions.totalShards}, Large threshold: ${apiOptions.largeThreshold}', + ) + ..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}'); + final client = NyxxGateway._(apiOptions, clientOptions); client