Merge pull request #476 from BigBotNetwork/greg-dev

v1.3.11
This commit is contained in:
Skidder 2020-05-13 18:22:36 +02:00 committed by GitHub
commit d546ed563a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 34 deletions

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Hadder</groupId>
<artifactId>Hadder</artifactId>
<version>1.3.3</version>
<version>1.3.11</version>
<name>Hadder</name>
<inceptionYear>2019</inceptionYear>
<description>Hadder is a multi-purpose Discord bot.</description>
@ -66,7 +66,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.1_148</version>
<version>4.1.1_149</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
@ -76,7 +76,7 @@
<dependency>
<groupId>com.rethinkdb</groupId>
<artifactId>rethinkdb-driver</artifactId>
<version>2.4.0</version>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@ -96,7 +96,7 @@
<dependency>
<groupId>com.sedmelluq</groupId>
<artifactId>lavaplayer</artifactId>
<version>1.3.47</version>
<version>1.3.48</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>

View file

@ -52,7 +52,7 @@ public class Hadder {
Rethink rethink = new Rethink(config);
rethink.connect();
DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.create(GatewayIntent.GUILD_MEMBERS, GatewayIntent.DIRECT_MESSAGE_REACTIONS, GatewayIntent.GUILD_PRESENCES, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.GUILD_EMOJIS, GatewayIntent.GUILD_MESSAGES);
DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.create(GatewayIntent.getIntents(GatewayIntent.ALL_INTENTS));
builder.setAutoReconnect(true);
builder.setShardsTotal(1);

View file

@ -21,12 +21,10 @@ import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlNonExistenceError;
import com.rethinkdb.gen.exc.ReqlOpFailedError;
import com.rethinkdb.net.Connection;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Field;
import java.util.NoSuchElementException;
public class Rethink {
private RethinkDB r = RethinkDB.r;
@ -52,33 +50,12 @@ public class Rethink {
}
}
private JSONArray getAsArray(String table, String where, String value) {
try {
String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn);
return new JSONArray(string);
} catch (NoSuchElementException e) {
return null;
} catch (Exception e) {
e.printStackTrace();
}
return new JSONArray();
}
public Object get(String table, String where, String value, String column) {
JSONArray array = this.getAsArray(table, where, value);
if (array.length() > 0)
if (array.getJSONObject(0).has(column))
return array.getJSONObject(0).get(column);
else return null;
else return null;
}
public Object getByID(String table, String where, String column) {
return r.table(table).get(where).getField(column).run(conn);
return r.table(table).get(where).getField(column).run(conn).first();
}
public JSONObject getObjectByID(String table, String id) {
String response = r.table(table).get(id).toJson().run(conn);
String response = String.valueOf(r.table(table).get(id).toJson().run(conn).first());
try {
return new JSONObject(response);
} catch (JSONException e) {
@ -163,7 +140,7 @@ public class Rethink {
}
}
public void pushServer(RethinkServer server) {
public void push(RethinkServer server) {
JSONObject object = new JSONObject();
for (Field field : server.getClass().getDeclaredFields()) {
if (!field.getName().equals("rethink")) {
@ -177,7 +154,7 @@ public class Rethink {
r.table("server").get(server.getId()).update(object.toMap()).run(conn);
}
public void pushUser(RethinkUser user) {
public void push(RethinkUser user) {
JSONObject object = new JSONObject();
for (Field field : user.getClass().getDeclaredFields()) {
if (!field.getName().equals("rethink")) {

View file

@ -128,6 +128,6 @@ public class RethinkServer {
}
public void push() {
rethink.pushServer(this);
rethink.push(this);
}
}

View file

@ -76,6 +76,6 @@ public class RethinkUser {
}
public void push() {
rethink.pushUser(this);
rethink.push(this);
}
}