requestMembers method
void
requestMembers(})
Allows to request members objects from gateway
guild
can be either Snowflake or Iterable
Implementation
void requestMembers(/* Snowflake|Iterable<Snowflake> */ dynamic guild,
{String? query, Iterable<Snowflake>? userIds, int limit = 0, bool presences = false, String? nonce}) {
if (query != null && userIds != null) {
throw ArgumentError("Both `query` and userIds cannot be specified.");
}
dynamic guildPayload;
if (guild is Snowflake) {
if(!this.guilds.contains(guild)) {
throw InvalidShardException._new("Cannot request member for guild on wrong shard");
}
guildPayload = [guild.toString()];
} else if (guild is Iterable<Snowflake>) {
if(!this.guilds.any((element) => guild.contains(element))) {
throw InvalidShardException._new("Cannot request member for guild on wrong shard");
}
guildPayload = guild.map((e) => e.toString()).toList();
} else {
throw ArgumentError("Guild has to be either Snowflake or Iterable<Snowflake>");
}
final payload = <String, dynamic>{
"guild_id": guildPayload,
"limit": limit,
"presences": presences,
if (query != null) "query": query,
if (userIds != null) "user_ids": userIds.map((e) => e.toString()).toList(),
if (nonce != null) "nonce": nonce
};
this.send(OPCodes.requestGuildMember, payload);
}