removeIcon method

Future<void> removeIcon()

Remove the icon of the role.

Your guild requires the GuildFeature.roleIcons to perform this action, otherwise throw MissingFeatureException.

Example :

import 'package:mineral/api.dart'; 👈 // then you can use GuildFeature enum

final Role? role = guild.roles.cache.get('240561194958716924');
final bool hasFeature = guild.features.contains(GuildFeature.roleIcons);

if (hasFeature && role != null) {
  await role.removeIcon();
}

Implementation

Future<void> removeIcon () async {
  if (!manager.guild.features.contains(GuildFeature.roleIcons)) {
    throw MissingFeatureException(cause: "Guild ${manager.guild.name} has no 'ROLE_ICONS' feature.");
  }

  Http http = ioc.singleton(Service.http);
  Response response = await http.patch(url: "/guilds/${manager.guild.id}/roles/$id", payload: { 'icon': null });
  if (response.statusCode == 200) {
    _icon = null;
  }
}