setLabel method

Future<void> setLabel(
  1. String label, {
  2. String? reason,
})

Modifies the label of the role.

Example :

final Role? role = guild.roles.cache.get('240561194958716924');
if (role != null) {
  await role.setLabel('New label');
}

Implementation

Future<void> setLabel (String label, { String? reason }) async {
  Response response = await ioc.use<DiscordApiHttpService>().patch(url: "/guilds/${manager.guild.id}/roles/$id")
    .payload({ 'name': label })
    .auditLog(reason)
    .build();

  if (response.statusCode == 200) {
    _label = label;
  }
}