mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-23 06:09:02 +00:00
added possibility to the ID of a user instead of a mention for a member parameter
This commit is contained in:
@@ -12,6 +12,7 @@ import dev.sheldan.abstracto.core.command.execution.*;
|
|||||||
import dev.sheldan.abstracto.core.command.execution.UnParsedCommandParameter;
|
import dev.sheldan.abstracto.core.command.execution.UnParsedCommandParameter;
|
||||||
import dev.sheldan.abstracto.core.Constants;
|
import dev.sheldan.abstracto.core.Constants;
|
||||||
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
|
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
|
||||||
|
import dev.sheldan.abstracto.core.exception.MemberNotFoundException;
|
||||||
import dev.sheldan.abstracto.core.exception.RoleNotFoundInDBException;
|
import dev.sheldan.abstracto.core.exception.RoleNotFoundInDBException;
|
||||||
import dev.sheldan.abstracto.core.models.database.ARole;
|
import dev.sheldan.abstracto.core.models.database.ARole;
|
||||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||||
@@ -165,7 +166,15 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
|||||||
} else if(param.getType().equals(TextChannel.class)){
|
} else if(param.getType().equals(TextChannel.class)){
|
||||||
parsedParameters.add(channelIterator.next());
|
parsedParameters.add(channelIterator.next());
|
||||||
} else if(param.getType().equals(Member.class)) {
|
} else if(param.getType().equals(Member.class)) {
|
||||||
parsedParameters.add(memberIterator.next());
|
if(StringUtils.isNumeric(value)) {
|
||||||
|
Member memberById = message.getGuild().getMemberById(Long.parseLong(value));
|
||||||
|
if(memberById == null) {
|
||||||
|
throw new MemberNotFoundException();
|
||||||
|
}
|
||||||
|
parsedParameters.add(memberById);
|
||||||
|
} else {
|
||||||
|
parsedParameters.add(memberIterator.next());
|
||||||
|
}
|
||||||
} else if(param.getType().equals(Emote.class)) {
|
} else if(param.getType().equals(Emote.class)) {
|
||||||
// TODO maybe rework, this fails if two emotes are needed, and the second one is an emote, the first one a default one
|
// TODO maybe rework, this fails if two emotes are needed, and the second one is an emote, the first one a default one
|
||||||
// the second one shadows the first one, and there are too little parameters to go of
|
// the second one shadows the first one, and there are too little parameters to go of
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<#include "member_not_foound_exception_text">
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package dev.sheldan.abstracto.core.exception;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.templating.Templatable;
|
||||||
|
|
||||||
|
public class MemberNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||||
|
|
||||||
|
public MemberNotFoundException() {
|
||||||
|
super("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateName() {
|
||||||
|
return "member_not_found_exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTemplateModel() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Member not found.
|
||||||
Reference in New Issue
Block a user