Search in sources :

Example 1 with AutomessageModel

use of tk.ardentbot.rethink.models.AutomessageModel in project Ardent by adamint.

the class Automessage method getMessagesAndChannel.

public static Triplet<String, String, String> getMessagesAndChannel(Guild guild) {
    Triplet<String, String, String> triplet;
    check(guild);
    List<HashMap> getAutomessages = ((Cursor<HashMap>) r.db("data").table("automessages").filter(row -> row.g("guild_id").eq(guild.getId())).run(connection)).toList();
    if (getAutomessages.size() > 0) {
        AutomessageModel automessageModel = asPojo(getAutomessages.get(0), AutomessageModel.class);
        String channel;
        String welcome;
        String goodbye;
        if (automessageModel.getChannel_id().equalsIgnoreCase("000"))
            channel = null;
        else
            channel = automessageModel.getChannel_id();
        if (automessageModel.getWelcome().equalsIgnoreCase("000"))
            welcome = null;
        else
            welcome = automessageModel.getWelcome();
        if (automessageModel.getGoodbye().equalsIgnoreCase("000"))
            goodbye = null;
        else
            goodbye = automessageModel.getGoodbye();
        triplet = new Triplet<>(channel, welcome, goodbye);
    } else {
        triplet = new Triplet<>(null, null, null);
    }
    return triplet;
}
Also used : HashMap(java.util.HashMap) AutomessageModel(tk.ardentbot.rethink.models.AutomessageModel) Cursor(com.rethinkdb.net.Cursor)

Aggregations

Cursor (com.rethinkdb.net.Cursor)1 HashMap (java.util.HashMap)1 AutomessageModel (tk.ardentbot.rethink.models.AutomessageModel)1