Search in sources :

Example 1 with DiscordException

use of exceptions.DiscordException in project KaellyBot by Kaysoro.

the class DofusRequestCommand method getListRequestableFrom.

protected List<Requestable> getListRequestableFrom(String url, IMessage message, DiscordException notFound) {
    List<Requestable> result = new ArrayList<>();
    Language lg = Translator.getLanguageFrom(message.getChannel());
    try {
        Document doc = JSoupManager.getDocument(url);
        Elements elems = doc.getElementsByClass("ak-bg-odd");
        elems.addAll(doc.getElementsByClass("ak-bg-even"));
        for (Element element : elems) result.add(new Requestable(element.child(1).text(), element.child(1).select("a").attr("href")));
    } catch (IOException e) {
        ExceptionManager.manageIOException(e, message, this, lg, notFound);
        return new ArrayList<>();
    } catch (Exception e) {
        ExceptionManager.manageException(e, message, this, lg);
        return new ArrayList<>();
    }
    return result;
}
Also used : Language(enums.Language) Requestable(util.Requestable) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) IOException(java.io.IOException) DiscordException(exceptions.DiscordException)

Aggregations

Language (enums.Language)1 DiscordException (exceptions.DiscordException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Document (org.jsoup.nodes.Document)1 Element (org.jsoup.nodes.Element)1 Elements (org.jsoup.select.Elements)1 Requestable (util.Requestable)1