delete method

Future<void> delete({
  1. String? reason,
})

Removes the current this from the MemberRoleManager's cache

Example :

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

You can specify a reason for this action

Example :

await role.delete(reason: 'I will destroy this..');

You can't delete @everyone and managed roles.

Implementation

Future<void> delete ({ String? reason }) async {
  if (isManaged || label == '@everyone') {
    return;
  }

  Response response = await ioc.use<DiscordApiHttpService>().destroy(url: "/guilds/${manager.guild.id}/roles/$id")
    .auditLog(reason)
    .build();

  if (response.statusCode == 200) {
    manager.cache.remove(id);
  }
}