fromID static method

Future<Guild> fromID(
  1. String id
)

Retrieves a Discord Guild from an id

Implementation

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

  return Guild(
    id: decodedResponse["id"],
    name: decodedResponse["name"],
    owner: guildOwner,
  );
}