use of enums.SuperTypeEquipment in project KaellyBot by Kaysoro.
the class ItemCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Matcher m = getMatcher(message);
Language lg = Translator.getLanguageFrom(message.getChannel());
m.find();
if (message.getChannel().getModifiedPermissions(ClientConfig.DISCORD().getOurUser()).contains(Permissions.USE_EXTERNAL_EMOJIS) && ClientConfig.DISCORD().getOurUser().getPermissionsForGuild(message.getGuild()).contains(Permissions.USE_EXTERNAL_EMOJIS)) {
String normalName = Normalizer.normalize(m.group(2).trim(), Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").toLowerCase();
BestMatcher matcher = new BestMatcher(normalName);
try {
for (TypeEquipment equip : TypeEquipment.values()) {
String[] names = equip.getNames(lg);
gatherData(message, matcher, names, normalName, equip, notFoundItem);
}
if (matcher.isEmpty())
for (SuperTypeEquipment type : SuperTypeEquipment.values()) matcher.evaluateAll(getListRequestableFrom(getSearchURL(type.getUrl(lg), normalName, null, lg), message, notFoundItem));
if (matcher.isUnique()) {
// We have found it !
Embedded item = Item.getItem(lg, Translator.getLabel(lg, "game.url") + matcher.getBest().getUrl());
if (m.group(1) != null)
Message.sendEmbed(message.getChannel(), item.getMoreEmbedObject(lg));
else
Message.sendEmbed(message.getChannel(), item.getEmbedObject(lg));
} else if (// Too much items
!matcher.isEmpty())
tooMuchItems.throwException(message, this, lg, matcher.getBests());
else
// empty
notFoundItem.throwException(message, this, lg);
} catch (IOException e) {
ExceptionManager.manageIOException(e, message, this, lg, notFoundItem);
}
return true;
} else
noExternalEmojiPermission.throwException(message, this, lg);
}
return false;
}
Aggregations