sync method

Future<Map<Snowflake, Role>> sync()

Implementation

Future<Map<Snowflake, Role>> sync () async {
  Response response = await ioc.use<HttpService>().get(url: "/guilds/${manager.guild.id}/members/$memberId");
  if(response.statusCode == 200) {
    cache.clear();
    dynamic payload = jsonDecode(response.body)['roles'];

    for(dynamic element in payload) {
      final Role? role = manager.cache.get(element);
      if(role != null) {
        cache.putIfAbsent(role.id, () => role);
      }
    }
  }

  return cache;
}