remove method
Remove a Role from the GuildMember
Example :
final Role? role = guild.roles.cache.get('446556480850755604');
final GuildMember? member = guild.members.cache.get('240561194958716924');
if (member != null && role != null) {
await member.roles.remove(role.id)
}
You can pass a reason for the audit logs.
Example :
await member.roles.remove('446556480850755604', reason: 'Hello, World!');
Implementation
Future<void> remove (Snowflake id, {String? reason}) async {
Map<String, String> headers = {};
if(reason != null) {
headers.putIfAbsent('X-Audit-Log-Reason', () => reason);
}
Response response = await ioc.use<HttpService>().destroy(
url: '/guilds/${manager.guild.id}/members/$memberId/roles/$id',
headers: headers
);
if(response.statusCode == 204) {
cache.remove(id);
}
}