setAvatar method

Future<void> setAvatar(
  1. String avatar, {
  2. String? reason,
})

Update the avatar of this

Example :

await webhook.setAvatar('assets/images/my_picture.png');

Implementation

Future<void> setAvatar (String avatar, { String? reason }) async {
  String path = await Helper.getPicture(avatar);
  Response response = await ioc.use<DiscordApiHttpService>().patch(url: "/webhooks/$id")
    .payload({ 'avatar': path })
    .auditLog(reason)
    .build();

  if (response.statusCode == 200) {
    avatar = path;
  }
}