fixed db and reworked bans
This commit is contained in:
@@ -9,8 +9,6 @@ import net.nevet5gi.buzzbot.objects.WarnData;
|
||||
import java.sql.*;
|
||||
|
||||
public class SqlDB {
|
||||
//TODO Make this a two way class for reading and writing from db
|
||||
|
||||
private Connection connect;
|
||||
private Statement statement;
|
||||
private ResultSet resultSet;
|
||||
@@ -27,7 +25,7 @@ public class SqlDB {
|
||||
|
||||
public void insertBan(BanData ban, String table) {
|
||||
try {
|
||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + ban.getUserId() + ", '" + ban.getUserName() + "', '" + ban.getUserDiscriminator() + "', '" + ban.getDate() + "', '" + ban.getTime() + "', " + ban.getBanType() + ", " + ban.getBanLength() + ", '" + ban.getBanReason() + "', '" + ban.getModName() + "', " + ban.getModId() + ", '" + ban.getServerName() + "', " + ban.getServerId() + ")");
|
||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + ban.getUserId() + ", '" + ban.getUserName() + "', '" + ban.getDate() + "', '" + ban.getTime() + "', " + ban.getBanType() + ", " + ban.getBanLength() + ", '" + ban.getBanReason() + "', '" + ban.getModName() + "', " + ban.getModId() + ", '" + ban.getServerName() + "', " + ban.getServerId() + ")");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -37,7 +35,7 @@ public class SqlDB {
|
||||
|
||||
public void insertMute(MuteData mute, String table) {
|
||||
try {
|
||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + mute.getUserId() + ", '" + mute.getUserName() + "', '" + mute.getUserDiscriminator() + "', '" + mute.getDate() + "', '" + mute.getTime() + "', " + mute.getMuteLength() + ", '" + mute.getMuteReason() + "', '" + mute.getModName() + "', " + mute.getModId() + ", '" + mute.getServerName() + "', " + mute.getServerId() + ")");
|
||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + mute.getUserId() + ", '" + mute.getUserName() + "', '" + mute.getDate() + "', '" + mute.getTime() + "', " + mute.getMuteLength() + ", '" + mute.getMuteReason() + "', '" + mute.getModName() + "', " + mute.getModId() + ", '" + mute.getServerName() + "', " + mute.getServerId() + ")");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -45,7 +43,7 @@ public class SqlDB {
|
||||
|
||||
public void insertWarn(WarnData warn, String table) {
|
||||
try {
|
||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + warn.getUserId() + ", '" + warn.getUserName() + "', '" + warn.getUserDiscriminator() + "', '" + warn.getDate() + "', '" + warn.getTime() + "', " + warn.getBanType() + ", " + warn.getBanLength() + ", '" + warn.getBanReason() + "', '" + warn.getModName() + "', " + warn.getModId() + ", '" + warn.getServerName() + "', " + warn.getServerId() + ")");
|
||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + warn.getUserId() + ", '" + warn.getUserName() + "', '" + warn.getDate() + "', '" + warn.getTime() + "', " + warn.getBanType() + ", " + warn.getBanLength() + ", '" + warn.getBanReason() + "', '" + warn.getModName() + "', " + warn.getModId() + ", '" + warn.getServerName() + "', " + warn.getServerId() + ")");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -60,18 +58,17 @@ public class SqlDB {
|
||||
resultSet = statement.executeQuery("SELECT * FROM " + table + " WHERE userId=" + userId);
|
||||
|
||||
while (resultSet.next()) {
|
||||
ban.setUserId(resultSet.getLong("userid"));
|
||||
ban.setUserName(resultSet.getString("username"));
|
||||
ban.setUserDiscriminator(resultSet.getInt("userdiscriminator"));
|
||||
ban.setDate(resultSet.getDate("bandate"));
|
||||
ban.setTime(resultSet.getTime("bantime"));
|
||||
ban.setBanType(resultSet.getBoolean("bantype"));
|
||||
ban.setBanLength(resultSet.getInt("banlength"));
|
||||
ban.setBanReason(resultSet.getString("banreason"));
|
||||
ban.setModName(resultSet.getString("modname"));
|
||||
ban.setModId(resultSet.getLong("modid"));
|
||||
ban.setServerName(resultSet.getString("servername"));
|
||||
ban.setServerId(resultSet.getLong("serverid"));
|
||||
ban.setUserId(resultSet.getLong("user_id"));
|
||||
ban.setUserName(resultSet.getString("user_name"));
|
||||
ban.setDate(resultSet.getDate("ban_date"));
|
||||
ban.setTime(resultSet.getTime("ban_time"));
|
||||
ban.setBanType(resultSet.getBoolean("ban_type"));
|
||||
ban.setBanLength(resultSet.getInt("ban_length"));
|
||||
ban.setBanReason(resultSet.getString("ban_reason"));
|
||||
ban.setModName(resultSet.getString("mod_name"));
|
||||
ban.setModId(resultSet.getLong("mod_id"));
|
||||
ban.setServerName(resultSet.getString("server_name"));
|
||||
ban.setServerId(resultSet.getLong("server_id"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@@ -89,9 +86,8 @@ public class SqlDB {
|
||||
resultSet = statement.executeQuery("SELECT * FROM " + table + "WHERE userId=" + userId);
|
||||
|
||||
while (resultSet.next()) {
|
||||
mute.setUserId(resultSet.getLong("userid"));
|
||||
mute.setUserName(resultSet.getString("username"));
|
||||
mute.setUserDiscriminator(resultSet.getInt("userdiscriminator"));
|
||||
mute.setUserId(resultSet.getLong("user_id"));
|
||||
mute.setUserName(resultSet.getString("user_name"));
|
||||
//mute.setDate(resultSet.);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@@ -108,9 +104,8 @@ public class SqlDB {
|
||||
resultSet = statement.executeQuery("SELECT * FROM " + table + "WHERE userId=" + userId);
|
||||
|
||||
while (resultSet.next()) {
|
||||
warn.setUserId(resultSet.getLong("userid"));
|
||||
warn.setUserName(resultSet.getString("username"));
|
||||
warn.setUserDiscriminator(resultSet.getInt("userdiscriminator"));
|
||||
warn.setUserId(resultSet.getLong("user_id"));
|
||||
warn.setUserName(resultSet.getString("user_name"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@@ -121,7 +116,7 @@ public class SqlDB {
|
||||
|
||||
public void addGuild(GuildData guild) {
|
||||
try {
|
||||
statement.executeUpdate("INSERT INTO guild_settings VALUES (\"" + guild.getName() + "\", " + guild.getId() + ", \"" + guild.getGroup() + "\", " + guild.getProfanityLevel() + ")");
|
||||
statement.executeUpdate("INSERT INTO guild_settings VALUES ('" + guild.getName() + "', " + guild.getId() + ", '" + guild.getGroup() + "', " + guild.getProfanityLevel() + ")");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user