setUnicodeEmoji method

Future<void> setUnicodeEmoji(
  1. String unicode, {
  2. String? reason,
})

Define the unicodeEmoji of the role from String.

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.setUnicodeEmoji('😍');
}

Implementation

Future<void> setUnicodeEmoji (String unicode, { 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({ 'unicode_emoji': unicode })
    .auditLog(reason)
    .build();

  if (response.statusCode == 200) {
    _unicodeEmoji = unicode;
  }
}