setColor method

Future<void> setColor(
  1. Color color
)

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) async {

  int _color = Helper.toRgbColor(color);
  Response response = await ioc.use<HttpService>().patch(url: "/guilds/${manager.guild.id}/roles/$id", payload: { 'color': _color });
  if (response.statusCode == 200) {
    this._color = _color;
  }
}