Search in sources :

Example 1 with TypeEquipment

use of enums.TypeEquipment 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;
}
Also used : SuperTypeEquipment(enums.SuperTypeEquipment) SuperTypeEquipment(enums.SuperTypeEquipment) TypeEquipment(enums.TypeEquipment) Language(enums.Language) Matcher(java.util.regex.Matcher) Embedded(data.Embedded) IOException(java.io.IOException)

Aggregations

Embedded (data.Embedded)1 Language (enums.Language)1 SuperTypeEquipment (enums.SuperTypeEquipment)1 TypeEquipment (enums.TypeEquipment)1 IOException (java.io.IOException)1 Matcher (java.util.regex.Matcher)1