fetch method
Implementation
Future<Message> fetch(String id, { bool preferCached = true }) async {
if (preferCached && cache[id] != null) {
return cache[id] as Message;
}
var res = await http.get(
Uri.parse(
client.clientConfig.apiUrl +
'/channels/${channel.id}/messages/$id'
),
headers: client._authHeaders
);
var msgData = jsonDecode(res.body);
var attachment = msgData['attachment'];
var msg = Message(
client,
id: id,
author: await client.users.fetch(msgData['author']),
channel: channel,
nonce: msgData['nonce'],
content: msgData['content'],
attachment: attachment == null ? null : File.fromJSON(attachment)
);
cache[id] = msg;
return msg;
}