fromID static method

Future<User> fromID(
  1. String id
)

Retrieves a Discord User from an id

Implementation

static Future<User> fromID(String id) async {
  http.Response response = await http
      .get(Uri.parse("${constants.apiBaseURL}/users/$id"), headers: {
    "Authorization": "Bot ${config.botToken}",
    "Content-Type": "application/json",
  });
  if (response.statusCode != 200) {
    throw Exception("Failed to fetch the user with the ID $id.");
  }
  Map<String, dynamic> decodedResponse = jsonDecode(response.body);
  return User(
    id: decodedResponse["id"],
    username: decodedResponse["username"],
    discriminator: decodedResponse["discriminator"],
    isBot: decodedResponse["bot"] ?? false,
  );
}