GuildMember.from constructor
GuildMember.from({
- required dynamic user,
- required GuildRoleManager roles,
- required Guild guild,
- dynamic member,
- required VoiceManager voice,
Implementation
factory GuildMember.from({ required user, required GuildRoleManager roles, required Guild guild, dynamic member, required VoiceManager voice }) {
MemberRoleManager memberRoleManager = MemberRoleManager(manager: roles, memberId: user.id);
for (var element in (member['roles'] as List<dynamic>)) {
Role? role = roles.cache.get(element);
if (role != null) {
memberRoleManager.cache.putIfAbsent(role.id, () => role);
}
}
return GuildMember(
user,
member['nick'],
member['avatar'] != null ? ImageFormater(member['avatar'], 'guilds/${guild.id}/users/${user.id}/avatars') : null,
DateTime.parse(member['joined_at']),
member['premium_since'] != null ? DateTime.parse(member['premium_since']) : null,
member['permissions'],
member['pending'] == true,
member['communication_disabled_until'] != null ? DateTime.parse(member['communication_disabled_until']) : null,
memberRoleManager,
voice,
guild
);
}