removeIcon method
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 ({ String? reason }) async {
if (!manager.guild.features.contains(GuildFeature.roleIcons)) {
throw MissingFeatureException("Guild ${manager.guild.name} has no 'ROLE_ICONS' feature.");
}
Response response = await ioc.use<DiscordApiHttpService>().patch(url: "/guilds/${manager.guild.id}/roles/$id")
.payload({ 'icon': null })
.auditLog(reason)
.build();
if (response.statusCode == 200) {
_icon = null;
}
}