init method

Future<void> init()

Initialize the kernel.

Implementation

Future<void> init () async {
  CollectorService();

  container.bind((_) => _console);
  await _environment.load();

  final DiscordApiHttpService http = DiscordApiHttpService('${Constants.host}${Constants.baseUri}');
  http.defineHeader(header: 'Content-Type', value: 'application/json');
  http.defineHeader(header: 'User-Agent', value: '${Constants.name} (${Constants.githubURL}, ${Constants.version})');
  container.bind((_) => http);

  String? token = _environment.get('APP_TOKEN');
  if (token == null) {
    throw TokenException('APP_TOKEN is not defined in your environment');
  }

  await packages.load();

  final String? shardsCount = _environment.get('SHARDS_COUNT');

  ShardManager shardManager = ShardManager(http, token, intents.list);
  shardManager.start(shardsCount: (shardsCount != null ? int.tryParse(shardsCount) : null));
}