build method
Implementation
Client build() {
_watcherConfig.watchedFiles.add(_scaffold.entrypoint);
ioc
..bind<ScaffoldContract>(() => _scaffold)
..bind<LoggerContract>(() => _logger)
..bind<EnvContract>(() => _env);
_validateEnvironment();
_createCache();
final token = _env.get<String>(AppEnv.token);
final httpVersion = int.parse(_env.get(AppEnv.httpVersion));
final shardVersion = int.parse(_env.get(AppEnv.wssVersion));
final intent = int.parse(_env.get(AppEnv.intent));
final http = HttpClient(
config: HttpClientConfigImpl(
baseUrl: 'https://discord.com/api/v$httpVersion',
headers: {
Header.userAgent('Mineral'),
Header.contentType('application/json'),
}));
final shardConfig =
ShardingConfig(token: token, intent: intent, version: shardVersion);
final packetListener = PacketListener();
final eventListener = EventListener();
final providerManager = ProviderManager();
final globalStateManager = ioc.make(GlobalStateManager.new);
final kernel = Kernel(
_hasDefinedDevPort,
_devPort,
watcherConfig: _watcherConfig,
logger: _logger,
environment: _env,
httpClient: http,
config: shardConfig,
packetListener: packetListener,
providerManager: providerManager,
eventListener: eventListener,
globalState: globalStateManager,
);
ioc
..bind<MarshallerContract>(() => Marshaller(_logger, _cache!))
..bind<DataStoreContract>(() => DataStore(http))
..bind<CommandInteractionManagerContract>(CommandInteractionManager.new);
packetListener
..kernel = kernel
..init();
final client = Client(kernel);
for (final provider in _providers) {
providerManager.register(provider(client));
}
return client;
}