lphillips / SecretHitlerDiscord

A discord bot for the famous board game Secret Hitler
Other
1 stars 0 forks source link

Improve user name recognition for invitations and nominations #5

Open lphillips opened 3 years ago

lphillips commented 3 years ago

The user must type in Discord user names for the -invite and -nominate commands (and other commands as well). If a user name has whitespace, then it must be wrapped with double quotes to properly parse and send the entire user name to the Discord API, which is unintuitive for most users. Also, while specifying a user's nickname does work, embeds for the Secret Hitler app are using the underlying account name for the game UI instead of the nickname, which is confusing because now that user is using one name in Discord and a different name in Secret Hitler.

Ideally, we can accomplish the following:

bsmccain commented 3 years ago

Doing a little research and testing, the user name conversion code is actually part of the API. It's handled through parameter decorators that I don't fully understand how they work, but it is fairly robust, in that it will try looking for the specified name by username, nickname, etc. However, it is what requires the " around the name if there is a space. We could probably remove those decorators and do the work ourselves in some way, but it will certainly be more work. I did determine that it will accept names like @, which works for nicknames with or without white space. So we do need to handle the exception that is thrown when the conversion fails, but it might be easier just to document in the invite and nominate commands to use the @ syntax. That also guarantees they pick who they want, since discord will show a drop down to select someone as soon as you start with the @.

Adding nominate by number would definitely require removing the decorator and processing the parameters manually. Not sure it is necessarily easier to use than the @ syntax anyway, especially since the player list will scroll off the screen later in the game. As it is implemented currently, the player list gets shuffled when the game starts, so it might be confusing who is what number. We could certainly implement something to display player numbers, but again, I'm not sure that's really easier for the user than using @, since they should be familiar with that notation already.

For displaying the nickname, that's actually a very simple change but it also shows up in multiple places (like letting the fascists know who the other fascists are). I'm going to make a new issue for that piece and we can use this issue to track fixing the invite and nominate commands.