setColor method

Future<void> setColor(
  1. Color color, {
  2. String? reason,
})

Modifies the color of the role.

Example :

import 'package:mineral/api.dart'; 👈 // then you can use Color class

final Role? role = guild.roles.cache.get('240561194958716924');
if (role != null) {
  await role.setColor(Color.cyan_600);
}

You can use a custom colour from a hexadecimal format.

Example :

await role.setColor(Color('#ffffff'));

Implementation

Future<void> setColor (Color color, { String? reason }) async {

  int _color = Helper.toRgbColor(color);
  Response response = await ioc.use<DiscordApiHttpService>().patch(url: "/guilds/${manager.guild.id}/roles/$id")
    .payload({ 'color': _color })
    .auditLog(reason)
    .build();

  if (response.statusCode == 200) {
    this._color = _color;
  }
}