use of enums.SuperTypeResource in project KaellyBot by Kaysoro.
the class ResourceCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Matcher m = getMatcher(message);
Language lg = Translator.getLanguageFrom(message.getChannel());
m.find();
String normalName = Normalizer.normalize(m.group(2).trim(), Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").toLowerCase();
BestMatcher matcher = new BestMatcher(normalName);
try {
for (TypeResource resource : TypeResource.values()) {
String[] names = resource.getNames(lg);
gatherData(message, matcher, names, normalName, resource, notFoundRsrc);
}
if (matcher.isEmpty())
for (SuperTypeResource type : SuperTypeResource.values()) matcher.evaluateAll(getListRequestableFrom(getSearchURL(type.getUrl(lg), normalName, null, lg), message, notFoundRsrc));
if (matcher.isUnique()) {
// We have found it !
Embedded resource = Resource.getResource(lg, Translator.getLabel(lg, "game.url") + matcher.getBest().getUrl());
if (m.group(1) != null)
Message.sendEmbed(message.getChannel(), resource.getMoreEmbedObject(lg));
else
Message.sendEmbed(message.getChannel(), resource.getEmbedObject(lg));
} else if (// Too much items
!matcher.isEmpty())
tooMuchRsrcs.throwException(message, this, lg, matcher.getBests());
else
// empty
notFoundRsrc.throwException(message, this, lg);
} catch (IOException e) {
ExceptionManager.manageIOException(e, message, this, lg, notFoundRsrc);
}
return true;
}
return false;
}
Aggregations