Skip to content

Commit

Permalink
feat(member argument): slice off Discord discriminators before perfor…
Browse files Browse the repository at this point in the history
…ming a query search (#301)
  • Loading branch information
favna authored Oct 16, 2021
1 parent 9097cf5 commit f6261ae
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/resolvers/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ async function resolveById(argument: string, guild: Guild): Promise<GuildMember
}

async function resolveByQuery(argument: string, guild: Guild): Promise<GuildMember | null> {
argument = argument.length > 5 && argument.at(-5) === '#' ? argument.slice(0, -5) : argument;

const members = await guild.members.fetch({ query: argument, limit: 1 }).catch(() => null);
return members?.first() ?? null;
}

0 comments on commit f6261ae

Please sign in to comment.