GuildMember.from constructor

GuildMember.from({
  1. required dynamic user,
  2. required GuildRoleManager roles,
  3. required Guild guild,
  4. required dynamic member,
  5. required VoiceManager voice,
})

Implementation

factory GuildMember.from({ required user, required GuildRoleManager roles, required Guild guild, required 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'],
    DateTime.parse(member['joined_at']),
    member['premium_since'],
    member['permissions'],
    member['pending'] == true,
    member['communication_disabled_until'],
    memberRoleManager,
    voice,
    guild,
    null,
  );
}