init method

Future<void> init()

Implementation

Future<void> init () async {
  await _environment.load();

  final HttpService http = HttpService(baseUrl: 'https://discord.com/api');
  http.defineHeader(header: 'Content-Type', value: 'application/json');
  container.bind((_) => http);

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

  await modules.load(this);
  await plugins.load();

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

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