Skip to content

Commit

Permalink
Allow User arg resolve target to check nicknames if in guild channel
Browse files Browse the repository at this point in the history
  • Loading branch information
zajrik committed Mar 14, 2017
1 parent 32f74aa commit fb33225
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/command/middleware/ResolveArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export function resolveArgs<T extends Bot, U extends Command<T>>(argTypes: { [na
let users: Collection<string, User> = (<U> this).bot.users.filter(a => normalizeUser(a.username).includes(normalized)
|| normalizeUser(`${a.username}#${a.discriminator}`).includes(normalized));

if (message.channel.type === 'text')
users = users.concat(new Collection(
message.guild.members
.filter(a => normalizeUser(a.displayName).includes(normalized))
.map(a => <[string, User]> [a.id, a.user])));

if (users.size > 1) throw String(`Found multiple potential matches for arg \`${name}\`:\n${
users.map(a => `\`${a.username}#${a.discriminator}\``).join(', ')
}\nPlease refine your search, or consider using an ID/mention\n${usage}`);
Expand Down

0 comments on commit fb33225

Please sign in to comment.