setBanner method

Future<void> setBanner(
  1. String filename
)

Update the banner of this

This method requires the feature GuildFeature.banner of this.

await guild.setBanner('assets/images/my_banner.png');

Implementation

Future<void> setBanner (String filename) async {
  if (!features.contains(GuildFeature.banner)) {
    throw MissingFeatureException('The $name guild does not have the ${GuildFeature.banner} feature.');
  }

  String file = await Helper.getPicture(filename);

  Response response = await ioc.use<DiscordApiHttpService>().patch(url: "/guilds/$id")
    .payload({ 'banner': file })
    .build();

  if (response.statusCode == 200) {
    _banner = ImageFormater(file, '');
  }
}