sync method
Implementation
Future<Map<Snowflake, T>> sync () async {
Response response = await ioc.use<DiscordApiHttpService>()
.get(url: "/channels/$_channelId/messages?limit=100")
.build();
dynamic payload = jsonDecode(response.body);
cache.clear();
for (final element in payload) {
if (_guildId != null) {
final Guild guild = ioc.use<MineralClient>().guilds.cache.getOrFail(_guildId);
Message message = Message.from(
channel: guild.channels.cache.getOrFail(_channelId),
payload: element
);
cache.putIfAbsent(message.id, () => message as T);
} else {
// @Todo add DM case
}
}
return cache;
}