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 {
  Http http = ioc.singleton(Service.http);

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