Error fixes, Bug fixes
This commit is contained in:
parent
e9514daf6f
commit
82a714791d
@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
mainClassName = 'me.savvy.rixa.Rixa'
|
||||
version '1.0'
|
||||
version '2.4'
|
||||
|
||||
jar {
|
||||
baseName = project.name
|
||||
@ -38,4 +38,4 @@ compileJava.options.encoding = 'UTF-8'
|
||||
compileJava.options.fork = true
|
||||
|
||||
// Change this if you are getting errors building
|
||||
compileJava.options.forkOptions.executable = 'C:\\Program Files\\Java\\jdk1.8.0_131\\bin\\javac.exe'
|
||||
compileJava.options.forkOptions.executable = 'C:\\Program Files\\Java\\jdk1.8.0_144\\bin\\javac.exe'
|
@ -92,7 +92,11 @@ public class Rixa {
|
||||
.database(String.valueOf(config.getJsonObject().getJSONObject("sql").getString("databaseName")))
|
||||
.auth(String.valueOf(config.getJsonObject().getJSONObject("sql").getString("userName")), String.valueOf(config.getJsonObject().getJSONObject("sql").getString("password")))
|
||||
.build();
|
||||
Arrays.stream(DatabaseTables.values()).forEach(databaseTables -> database.send(new Update(databaseTables.getQuery())));
|
||||
Arrays.stream(DatabaseTables.values()).forEach(databaseTables -> {
|
||||
getInstance().getLogger().info("Checking database table (creating if needed): " + databaseTables.toString());
|
||||
database.send(new Update(databaseTables.getQuery()));
|
||||
getInstance().getLogger().info("Done checking " + databaseTables.toString());
|
||||
});
|
||||
getInstance().setLanguageManager(new LanguageManager(new File("Rixa/languages/language.json")));
|
||||
try {
|
||||
int shards = 5;
|
||||
|
@ -31,11 +31,11 @@ public class RoleRewardsCommand implements CommandExec {
|
||||
setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
if (rixaGuild.getLevelsModule().getRoleRewards().containsKey(Integer.parseInt(args[2]))) {
|
||||
/*if (rixaGuild.getLevelsModule().getRoleRewards().containsKey(Integer.parseInt(args[2]))) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + args[0] + " <add/remove/list> [level] [role].").
|
||||
setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "add":
|
||||
break;
|
||||
@ -51,9 +51,9 @@ public class RoleRewardsCommand implements CommandExec {
|
||||
switch(args[1].toLowerCase()) {
|
||||
case "list":
|
||||
Map<Integer, String> rewards = new HashMap<>();
|
||||
rixaGuild.getLevelsModule().getRoleRewards().forEach((integer, s) -> {
|
||||
/* rixaGuild.getLevelsModule().getRoleRewards().forEach((integer, s) -> {
|
||||
|
||||
});
|
||||
});*/
|
||||
break;
|
||||
default:
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + args[0] + " <add/remove/list> [level] [role].").
|
||||
|
@ -49,7 +49,12 @@ public class LevelsCommand implements CommandExec {
|
||||
User author = member.getUser();
|
||||
UserData data = rixaGuild.getLevelsModule().getUserData(author.getId());
|
||||
String query = "SELECT * FROM `levels` WHERE `guild_id` = '" + rixaGuild.getGuild().getId() + "' ORDER BY `experience` DESC";
|
||||
ResultSet rs = Rixa.getDbManager().executeQuery(query);
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
rs = Rixa.getDatabase().getConnection().get().prepareStatement(query).executeQuery();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int rowNumber = 0;
|
||||
String rank = "Not found.";
|
||||
try {
|
||||
|
@ -11,6 +11,7 @@ import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class CheckGuildCommand implements CommandExec {
|
||||
@ -34,11 +35,11 @@ public class CheckGuildCommand implements CommandExec {
|
||||
if (member.getUser().getId().equalsIgnoreCase(event.getAuthor().getId())) continue;
|
||||
try {
|
||||
if (!(checkExists(member.getUser().getId()))) {
|
||||
PreparedStatement ps = Rixa.getDbManager().getConnection().prepareStatement("INSERT INTO `user` (`user_id`, `user_name`, `avatar_hash`) VALUES (?, ?, ?)");
|
||||
PreparedStatement ps = Rixa.getDatabase().getConnection().get().prepareStatement("INSERT INTO `user` (`user_id`, `user_name`, `avatar_hash`) VALUES (?, ?, ?)");
|
||||
ps.setString(1, member.getUser().getId());
|
||||
ps.setString(2, member.getUser().getName());
|
||||
ps.setString(3, member.getUser().getAvatarId());
|
||||
Rixa.getDbManager().executeUpdate(ps);
|
||||
ps.executeUpdate();
|
||||
updated++;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@ -50,12 +51,14 @@ public class CheckGuildCommand implements CommandExec {
|
||||
}
|
||||
|
||||
private boolean checkExists(String userId) {
|
||||
Result r = Result.ERROR;
|
||||
try {
|
||||
r = Rixa.getDbManager().checkExists("SELECT `user_id` FROM `user` WHERE `user_id` = '" + userId + "';");
|
||||
PreparedStatement ps = Rixa.getDatabase().getConnection().get().prepareStatement("SELECT `user_id` FROM `user` WHERE `user_id` = ?;");
|
||||
ps.setString(1, userId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
return rs.next();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return r == Result.TRUE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,12 @@
|
||||
package me.savvy.rixa.commands.owner;
|
||||
|
||||
import me.savvy.rixa.Rixa;
|
||||
import me.savvy.rixa.commands.handlers.Command;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.data.database.sql.DatabaseManager;
|
||||
import me.savvy.rixa.enums.Result;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class CleanGuildCommand implements CommandExec {
|
||||
|
||||
@Override
|
||||
@ -31,7 +23,7 @@ public class CleanGuildCommand implements CommandExec {
|
||||
}
|
||||
new MessageBuilder("Cleaning...").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
int cleaned = 0;
|
||||
DatabaseManager dbManager = Rixa.getDbManager();
|
||||
/* DatabaseManager dbManager = Rixa.getDbManager();
|
||||
ResultSet rs = dbManager.executeQuery("SELECT * FROM `core`;");
|
||||
try {
|
||||
while (rs.next()) {
|
||||
@ -59,11 +51,11 @@ public class CleanGuildCommand implements CommandExec {
|
||||
}
|
||||
}
|
||||
rs.getStatement().close();
|
||||
rs.close();
|
||||
rs.close();*/
|
||||
new MessageBuilder(event.getAuthor().getAsMention() + ", successfully cleaned " + cleaned + " guilds from the database").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} catch (SQLException e) {
|
||||
/*} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private boolean checkExists(String table, String guildId) {
|
||||
|
@ -2,48 +2,47 @@ package me.savvy.rixa.data.database.sql.other;
|
||||
|
||||
public enum DatabaseTables {
|
||||
|
||||
CORE("CREATE TABLE `core` ( `id` int(11) NOT NULL AUTO_INCREMENT, `guild_id` varchar(255) NOT NULL, `guild_name` varchar(255) NOT NULL," +
|
||||
CORE("CREATE TABLE IF NOT EXISTS `core` ( `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `guild_id` varchar(255) NOT NULL, `guild_name` varchar(255) NOT NULL," +
|
||||
" `description` text, `enlisted` tinyint(1) NOT NULL DEFAULT '0', `icon` varchar(255) DEFAULT NULL, `link` varchar(255) DEFAULT NULL," +
|
||||
" `keywords` text, `creation_date` varchar(255) NOT NULL DEFAULT 'N/A', `guild_region` varchar(255) NOT NULL DEFAULT 'N/A'," +
|
||||
" `guild_owner` varchar(255) NOT NULL DEFAULT 'N/A'\n" +
|
||||
"), PRIMARY KEY(`id`);"),
|
||||
");"),
|
||||
|
||||
LEVELS("CREATE TABLE `levels` ( `id` int(11) NOT NULL AUTO_INCREMENT, `guild_id` varchar(255) NOT NULL, `user_id` varchar(255) NOT NULL," +
|
||||
LEVELS("CREATE TABLE IF NOT EXISTS `levels` ( `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `guild_id` varchar(255) NOT NULL, `user_id` varchar(255) NOT NULL," +
|
||||
" `experience` int(90) NOT NULL\n" +
|
||||
"), PRIMARY KEY(`id`);"),
|
||||
");"),
|
||||
|
||||
MODULES("CREATE TABLE `modules` ( `guild_id` varchar(255) DEFAULT NULL, `levels` tinyint(1) NOT NULL DEFAULT '1'\n" +
|
||||
MODULES("CREATE TABLE IF NOT EXISTS `modules` ( `guild_id` varchar(255) DEFAULT NULL, `levels` tinyint(1) NOT NULL DEFAULT '1'\n" +
|
||||
")"),
|
||||
|
||||
MUSIC("CREATE TABLE `music` ( `guild_id` varchar(255) NOT NULL, `music_role` varchar(255) NOT NULL DEFAULT 'default_value'," +
|
||||
MUSIC("CREATE TABLE IF NOT EXISTS `music` ( `guild_id` varchar(255) NOT NULL UNIQUE PRIMARY KEY, `music_role` varchar(255) NOT NULL DEFAULT 'default_value'," +
|
||||
" `skip_amount` int(5) NOT NULL DEFAULT '0', `max_playlist_amount` int(5) NOT NULL DEFAULT '100', `enabled` tinyint(1) NOT NULL DEFAULT '0'\n" +
|
||||
"), PRIMARY KEY(`id`), UNIQUE KEY (`guild_id`);"),
|
||||
");"),
|
||||
|
||||
PERMISSIONS("CREATE TABLE `permissions` ( `role_id` varchar(255) NOT NULL, `guild_id` varchar(255) NOT NULL, `MUTE` tinyint(1) NOT NULL DEFAULT '0'," +
|
||||
PERMISSIONS("CREATE TABLE IF NOT EXISTS `permissions` ( `role_id` varchar(255) NOT NULL, `guild_id` varchar(255) NOT NULL, `MUTE` tinyint(1) NOT NULL DEFAULT '0'," +
|
||||
" `ADD_ROLE` tinyint(1) NOT NULL DEFAULT '0', `REMOVE_ROLE` tinyint(1) NOT NULL DEFAULT '0', `CLEAR_CHAT` tinyint(1) NOT NULL DEFAULT '0'," +
|
||||
" `ACCESS_CONFIG` tinyint(1) NOT NULL DEFAULT '0', `PM_MESSAGE` tinyint(1) NOT NULL DEFAULT '0', `KICK_MEMBER` tinyint(1) NOT NULL DEFAULT '0'," +
|
||||
" `BAN_MEMBER` tinyint(1) NOT NULL DEFAULT '0', `TOGGLE_RAIDMODE` tinyint(4) NOT NULL DEFAULT '0'\n" +
|
||||
")"),
|
||||
");"),
|
||||
|
||||
POLLS("CREATE TABLE `polls` ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `description` text," +
|
||||
POLLS("CREATE TABLE IF NOT EXISTS `polls` ( `id` int(9) NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) NOT NULL, `description` text," +
|
||||
" `option_1` varchar(255) DEFAULT NULL, `option_2` varchar(255) DEFAULT NULL, `option_3` varchar(255) DEFAULT NULL," +
|
||||
" `option_4` varchar(255) DEFAULT NULL, `option_5` varchar(255) DEFAULT NULL, `option_6` varchar(255) DEFAULT NULL," +
|
||||
" `option_7` varchar(255) DEFAULT NULL, `option_8` varchar(255) DEFAULT NULL, `option_9` varchar(255) DEFAULT NULL," +
|
||||
" `option_10` varchar(255) DEFAULT NULL\n" +
|
||||
"), PRIMARY KEY(`id`);"),
|
||||
" `option_10` varchar(255) DEFAULT NULL);"),
|
||||
|
||||
ROLE_REWARDS("CREATE TABLE `role_rewards` ( `guild_id` varchar(255) NOT NULL, `level` int(9) NOT NULL, `role_id` varchar(255) NOT NULL\n" +
|
||||
"), PRIMARY KEY(`guild_id`);"),
|
||||
ROLE_REWARDS("CREATE TABLE IF NOT EXISTS `role_rewards` ( `guild_id` varchar(255) NOT NULL PRIMARY KEY, `level` int(9) NOT NULL, `role_id` varchar(255) NOT NULL\n" +
|
||||
");"),
|
||||
|
||||
SETTINGS("CREATE TABLE `settings` ( `guild_id` varchar(255) NOT NULL, `log_enabled` tinyint(1) NOT NULL, `log_channel` varchar(255) NOT NULL," +
|
||||
SETTINGS("CREATE TABLE IF NOT EXISTS `settings` ( `guild_id` varchar(255) NOT NULL, `log_enabled` tinyint(1) NOT NULL, `log_channel` varchar(255) NOT NULL," +
|
||||
" `joinMessage` text NOT NULL, `quitMessage` text NOT NULL, `greetings` varchar(255) NOT NULL, `farewell` varchar(255) NOT NULL," +
|
||||
" `prefix` varchar(5) NOT NULL, `joinPm` text NOT NULL, `joinVerification` tinyint(1) NOT NULL, `defaultRole` varchar(255) NOT NULL, `muteRole` varchar(255) NOT NULL\n" +
|
||||
")"),
|
||||
|
||||
TWITTER("CREATE TABLE `twitter` (`guild_id` varchar(255) NOT NULL, `consumer_key` varchar(255) NOT NULL, `consumer_secret` varchar(255) NOT NULL, " +
|
||||
TWITTER("CREATE TABLE IF NOT EXISTS `twitter` (`guild_id` varchar(255) NOT NULL, `consumer_key` varchar(255) NOT NULL, `consumer_secret` varchar(255) NOT NULL, " +
|
||||
"`access_key` varchar(255) NOT NULL, `access_secret` varchar(255) NOT NULL, `tweet_channel` varchar(255) NOT NULL, `updates_channel` varchar(255) NOT NULL)"),
|
||||
|
||||
USER("CREATE TABLE `user` (`user_id` varchar(255) NOT NULL, `user_name` varchar(255) NOT NULL, `avatar_hash` varchar(255) DEFAULT 'N/A'), UNIQUE KEY(`id`);"); // USER is mostly used for http://rixa.io.
|
||||
USER("CREATE TABLE IF NOT EXISTS `user` (`user_id` varchar(255) NOT NULL UNIQUE, `user_name` varchar(255) NOT NULL, `avatar_hash` varchar(255) DEFAULT 'N/A');"); // USER is mostly used for http://rixa.io.
|
||||
|
||||
private String query;
|
||||
|
||||
@ -51,7 +50,11 @@ public enum DatabaseTables {
|
||||
query = s;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
return this.query;
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ public class GuildEvent {
|
||||
@SubscribeEvent
|
||||
public void onNameUpdate(GuildUpdateNameEvent event) {
|
||||
try {
|
||||
PreparedStatement ps = Rixa.getDbManager().getConnection().prepareStatement("UPDATE `core` SET `guild_name` = ? WHERE `core`.`guild_id` = ?;");
|
||||
PreparedStatement ps = Rixa.getDatabase().getConnection().get().prepareStatement("UPDATE `core` SET `guild_name` = ? WHERE `core`.`guild_id` = ?;");
|
||||
ps.setString(1, event.getGuild().getName());
|
||||
ps.setString(2, event.getGuild().getId());
|
||||
Rixa.getDbManager().executeUpdate(ps);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -27,10 +27,10 @@ public class GuildEvent {
|
||||
@SubscribeEvent
|
||||
public void onIconUpdate(GuildUpdateIconEvent event) {
|
||||
try {
|
||||
PreparedStatement ps = Rixa.getDbManager().getConnection().prepareStatement("UPDATE `core` SET `icon` = ? WHERE `core`.`guild_id` = ?;");
|
||||
PreparedStatement ps = Rixa.getDatabase().getConnection().get().prepareStatement("UPDATE `core` SET `icon` = ? WHERE `core`.`guild_id` = ?;");
|
||||
ps.setString(1, event.getGuild().getIconId());
|
||||
ps.setString(2, event.getGuild().getId());
|
||||
Rixa.getDbManager().executeUpdate(ps);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -39,10 +39,10 @@ public class GuildEvent {
|
||||
@SubscribeEvent
|
||||
public void onOwnerUpdate(GuildUpdateOwnerEvent event) {
|
||||
try {
|
||||
PreparedStatement ps = Rixa.getDbManager().getConnection().prepareStatement("UPDATE `core` SET `guild_owner` = ? WHERE `core`.`guild_id` = ?;");
|
||||
PreparedStatement ps = Rixa.getDatabase().getConnection().get().prepareStatement("UPDATE `core` SET `guild_owner` = ? WHERE `core`.`guild_id` = ?;");
|
||||
ps.setString(1, event.getGuild().getOwner().getUser().getName());
|
||||
ps.setString(2, event.getGuild().getId());
|
||||
Rixa.getDbManager().executeUpdate(ps);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -51,10 +51,10 @@ public class GuildEvent {
|
||||
@SubscribeEvent
|
||||
public void onRegionUpdate(GuildUpdateRegionEvent event) {
|
||||
try {
|
||||
PreparedStatement ps = Rixa.getDbManager().getConnection().prepareStatement("UPDATE `core` SET `guild_region` = ? WHERE `core`.`guild_id` = ?;");
|
||||
PreparedStatement ps = Rixa.getDatabase().getConnection().get().prepareStatement("UPDATE `core` SET `guild_region` = ? WHERE `core`.`guild_id` = ?;");
|
||||
ps.setString(1, event.getGuild().getRegion().getName());
|
||||
ps.setString(2, event.getGuild().getId());
|
||||
Rixa.getDbManager().executeUpdate(ps);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user