setUnicodeEmoji method

Future<void> setUnicodeEmoji(
  1. String unicode
)

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) 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: { 'unicode_emoji': unicode });
  if (response.statusCode == 200) {
    _unicodeEmoji = unicode;
  }
}