veldtech / miki-bot

Miki Discord Bot
https://miki.bot
149 stars 48 forks source link

User B is selected if user B's name is a subset of user A #659

Closed Zenulous closed 4 years ago

Zenulous commented 4 years ago

Describe the bug

In the case no nickname is matched, FindUserByName matches the input to the first name it can find that starts with this input. This can lead to undesired effect for commands like ship.

To Reproduce Steps to reproduce the behavior:

  1. Have 2 users without nicknames with overlapping names (e.g. Zen and Zen1)
  2. >ship Zen1
  3. Zen is always matched

Expected behavior

The filter should not use StartsWith, instead it should be as strict as when matching nicknames.

Additional context

A further improvement could be that FindUserByName filters out # if it is present in the string (in case someone types User#0000 without actually tagging them)