add querying members by name without intent

This commit is contained in:
Skillz
2020-08-21 14:33:10 -04:00
parent ac20cffeb6
commit 80a2be0598
3 changed files with 19 additions and 2 deletions

View File

@@ -174,6 +174,19 @@ export async function getMember(guildID: string, id: string) {
return member;
}
/** Returns guild member objects for the specified user by their nickname/username.
*
* ⚠️ **ADVANCED USE ONLY: Your members will be cached in your guild most likely. Only use this when you are absolutely sure the member is not cached.**
*/
export async function getMembersByQuery(guildID: string, name: string, limit = 1) {
const guild = cache.guilds.get(guildID);
if (!guild) return;
return new Promise((resolve) => {
requestAllMembers(guild, resolve, { query: name, limit });
})
}
/** Create an emoji in the server. Emojis and animated emojis have a maximum file size of 256kb. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message, but not a JSON status code. If a URL is provided to the image parameter, Discordeno will automatically convert it to a base64 string internally. */
export async function createEmoji(
guildID: string,

View File

@@ -269,7 +269,7 @@ export function requestGuildMembers(
d: {
guild_id: guildID,
query: options?.query || "",
limit: options?.query || 0,
limit: options?.limit || 0,
presences: options?.presences || false,
user_ids: options?.userIDs,
nonce,

View File

@@ -372,7 +372,11 @@ export async function handleDiscordPayload(
if (options.chunk_index + 1 === options.chunk_count) {
fetchAllMembersProcessingRequests.delete(options.nonce);
resolve();
resolve(
options.members.map((member) =>
guild.members.get(member.user.id)
),
);
}
}
}