sync method

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

Implementation

Future<Map<Snowflake, Role>> sync () async {
  Response response = await ioc.use<DiscordApiHttpService>()
    .get(url: "/guilds/${manager.guild.id}/members/$memberId")
    .build();

  if (response.statusCode == 200) {
    cache.clear();
    dynamic payload = jsonDecode(response.body)['roles'];

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

  return cache;
}