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

Issues/60 #61

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,16 @@ private MessageParts getParts(MessageReceivedEvent event) {

// Check for prefix or alternate prefix (@mention cases)
if(prefix.equals(DEFAULT_PREFIX) || (altprefix != null && altprefix.equals(DEFAULT_PREFIX))) {
if(rawContent.startsWith("<@"+ event.getJDA().getSelfUser().getId()+">") ||
rawContent.startsWith("<@!"+ event.getJDA().getSelfUser().getId()+">")) {
if(rawContent.startsWith("<@"+ event.getJDA().getSelfUser().getId()+"> ") || //Ensure that there is a space between the command and the mention
rawContent.startsWith("<@!"+ event.getJDA().getSelfUser().getId()+"> ")) {
// Since we now use substring into makeMessageParts function and a indexOf here, we need to do a +1 to get the good substring
// On top of that we need to do another +1 because the default @mention prefix will always be followed by a space
// So we need to add 2 characters to get the correct substring
final int prefixLength = rawContent.indexOf('>') + 2;
return makeMessageParts(rawContent, prefixLength);
final int mentionEndIndex = rawContent.indexOf('>') + 1;
// Make sure that the content isn't just the mention
if (rawContent.length() >= mentionEndIndex + 1) {
// On top of that we need to do another +1 because the default @mention prefix will always be followed by a space
final int prefixLength = rawContent.indexOf('>') + 2;
return makeMessageParts(rawContent, prefixLength);
}
}
}

Expand Down