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

Add option to use bot mention as prefix #302

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SuSeu1414
Copy link
Contributor

I added an option to use bot mention as a command prefix. Might be useful when you have per-server prefixes and forget what prefix is used in a particular server. You can enable it with this code:

JDACommandConfig config = new JDACommandConfig();
config.useMentionPrefix(true);

It's disabled by default, so it won't change any behaviour until you turn it on

if (prefixFound == null) {
return;
}

String[] args = ACFPatterns.SPACE.split(msg.substring(prefixFound.length()), -1);
// str.replaceAll("^[ \t]+", "") - works like String.stripLeading() from Java 11
String[] args = ACFPatterns.SPACE.split(msg.substring(prefixFound.length()).replaceAll("^[ \\t]+", ""), -1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that this pattern should be cached

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now I'm using ACFPatterns.getPattern() which caches patterns

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