Prevent error in getByID function
This commit is contained in:
parent
5c5a53fdd2
commit
b308a8bc25
1 changed files with 6 additions and 3 deletions
|
|
@ -43,7 +43,11 @@ public class Mongo {
|
||||||
BasicDBObject whereQuery = new BasicDBObject();
|
BasicDBObject whereQuery = new BasicDBObject();
|
||||||
whereQuery.put(where, what);
|
whereQuery.put(where, what);
|
||||||
FindIterable<Document> it = collection.find(whereQuery);
|
FindIterable<Document> it = collection.find(whereQuery);
|
||||||
return it.cursor().next().get(column);
|
try {
|
||||||
|
return it.cursor().next().get(column);
|
||||||
|
} catch (NoSuchElementException ignore) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getObjectByID(String collection, String id) {
|
public JSONObject getObjectByID(String collection, String id) {
|
||||||
|
|
@ -133,8 +137,7 @@ public class Mongo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasStarboardMessage(String message_id) {
|
public boolean hasStarboardMessage(String message_id) {
|
||||||
this.getByID("stars", "id", message_id, "guild");
|
return this.getByID("stars", "id", message_id, "guild") != null;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertStarboardMessage(String message_id, String guild_id, String starboard_message_id) {
|
public void insertStarboardMessage(String message_id, String guild_id, String starboard_message_id) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue