Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User name auto complete on certain commands #32

Merged
merged 5 commits into from
Oct 12, 2019

Conversation

nD00rn
Copy link
Contributor

@nD00rn nD00rn commented Oct 4, 2019

Describe the pull request

Certain commands in the Twitch chat require a user name to be entered
after the command. This PR enforces the auto completion to only
suggest user names and not to suggest any of the available emotes for
the user when providing the first argument.

This feature will work for the following commands at this moment of
writing.

/ban
/block
/mod
/purge
/timeout
/unban
/unblock
/unmod
/untimeout
/unvip
/user
/vip
/w

Why

This prevents the user from entering an emote instead a username when
for example trying to ban someone.

How

Whenever the 'tab' key is pressed it checks if the one of the previous mentioned commands is typed in, next it checks if the word the user currently is typing is the first argument after the command. If this first argument check was not in place the user would not be able to auto complete any available emote.

The commands which are processed like this are described in the Commands.ts found in the constants folder. In the command description it states if a username is an argument or not.

nD00rn and others added 5 commits October 4, 2019 23:22
Certain commands in the Twitch chat require a user name to be entered
after the command. This commit enforces the auto completion to only
suggest user names and not to suggest any of the available emotes for
the user when providing the first argument.

This feature will work for the following commands at this moment of
writing.

/ban
/block
/mod
/purge
/timeout
/unban
/unblock
/unmod
/untimeout
/unvip
/user
/vip
/w
@HiDeoo
Copy link
Owner

HiDeoo commented Oct 12, 2019

Thanks for the pull request. I slightly refactored the code:

  • There was way too much possible iterations for such a feature.
  • All the code was executed at every completion attempt while we can often bail out early.
  • There was an issue when you were trying to autocomplete the username while the second argument of the command was already given.

(I also updated the changelog 👍)

@HiDeoo HiDeoo closed this Oct 12, 2019
@HiDeoo HiDeoo reopened this Oct 12, 2019
@HiDeoo HiDeoo merged commit f32a828 into HiDeoo:master Oct 12, 2019
@nD00rn nD00rn deleted the userNameAutoComplete branch October 12, 2019 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants