Fixed outstanding errors.
This commit is contained in:
commit
1af78d65bf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,12 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: commons-io:commons-io:2.5">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.5/2852e6e05fbb95076fc091f6d1780f1f8fe35e0f/commons-io-2.5.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.5/commons-io-2.5.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.5/caf033a4a7c37b4a8ff3ea084cba591539b0b69/commons-io-2.5-sources.jar!/" />
|
||||
</SOURCES>
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
@ -1,11 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: net.sf.trove4j:trove4j:3.0.3">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/42ccaf4761f0dfdfa805c9e340d99a755907e2dd/trove4j-3.0.3.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/109c5be93362e6e651e417c51d1863477a22969c/trove4j-3.0.3-sources.jar!/" />
|
||||
</SOURCES>
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="Rixa:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/../../out/production/classes" />
|
||||
<output url="file://$MODULE_DIR$/../../build/classes/main" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../../src/main">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="Rixa:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output-test url="file://$MODULE_DIR$/../../out/test/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/../../build/classes/test" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../../src/test">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,14 +5,12 @@ import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
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.entities.Role;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.managers.GuildManager;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -89,7 +87,7 @@ public class ConfigCommand implements CommandExec {
|
||||
}
|
||||
String message;
|
||||
if (messages[1].equalsIgnoreCase("joinmessage")) {
|
||||
message = getMessage(messages, 2);
|
||||
message = getMessage(messages);
|
||||
if(event.getMessage().getMentionedChannels().size() > 0) {
|
||||
for (TextChannel messageChannel : event.getMessage().getMentionedChannels()) {
|
||||
message = message.replace(messageChannel.getAsMention(), "<#" + messageChannel.getId() + ">");
|
||||
@ -99,7 +97,7 @@ public class ConfigCommand implements CommandExec {
|
||||
new MessageBuilder("Successfully set Join Message to\n" + message.replace("{0}", event.getMember().getUser().getName())
|
||||
.replace("{1}", event.getGuild().getName())).setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else if (messages[1].equalsIgnoreCase("quitmessage")) {
|
||||
message = getMessage(messages, 2);
|
||||
message = getMessage(messages);
|
||||
if(event.getMessage().getMentionedChannels().size() > 0) {
|
||||
for (TextChannel messageChannel : event.getMessage().getMentionedChannels()) {
|
||||
message = message.replace(messageChannel.getAsMention(), "<#" + messageChannel.getId() + ">");
|
||||
@ -109,7 +107,7 @@ public class ConfigCommand implements CommandExec {
|
||||
new MessageBuilder("Successfully set Quit Message to\n" + message.replace("{0}", event.getMember().getUser().getName())
|
||||
.replace("{1}", event.getGuild().getName())).setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else if (messages[1].equalsIgnoreCase("joinpm")) {
|
||||
message = getMessage(messages, 2);
|
||||
message = getMessage(messages);
|
||||
if(event.getMessage().getMentionedChannels().size() > 0) {
|
||||
for (TextChannel messageChannel : event.getMessage().getMentionedChannels()) {
|
||||
message = message.replace(messageChannel.getAsMention(), "<#" + messageChannel.getId() + ">");
|
||||
@ -119,7 +117,7 @@ public class ConfigCommand implements CommandExec {
|
||||
new MessageBuilder("Successfully set Private Join Message to\n" + message.replace("{0}", event.getMember().getUser().getName())
|
||||
.replace("{1}", event.getGuild().getName())).setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else if (messages[1].equalsIgnoreCase("description")) {
|
||||
message = getMessage(messages, 2);
|
||||
message = getMessage(messages);
|
||||
rixaGuild.getGuildSettings().setDescription(message);
|
||||
new MessageBuilder("Successfully set Server Description to\n" + message.replace("{0}", event.getMember().getUser().getName())
|
||||
.replace("{1}", event.getGuild().getName())).setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
@ -275,9 +273,9 @@ public class ConfigCommand implements CommandExec {
|
||||
return builder.setColor(member.getColor()).setTitle(String.format("Config: %s", member.getGuild().getId()));
|
||||
}
|
||||
|
||||
private String getMessage(String[] messages, int argToBegin) {
|
||||
private String getMessage(String[] messages) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(int i = argToBegin; i < messages.length; i++) {
|
||||
for(int i = 2; i < messages.length; i++) {
|
||||
builder.append(messages[i]).append(" ");
|
||||
}
|
||||
return builder.toString().trim();
|
||||
|
@ -28,7 +28,7 @@ public class InfoCommand implements CommandExec {
|
||||
EmbedBuilder messageEmbed = new EmbedBuilder();
|
||||
User botOwner = event.getJDA().getUserById("202944101333729280");
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss");
|
||||
Date date1 = new Date(Rixa.getInstance().getTimeUp());
|
||||
Date date1 = new Date(Rixa.getTimeUp());
|
||||
Date date2 = new Date();
|
||||
long difference = date2.getTime() - date1.getTime();
|
||||
long seconds = difference / 1000;
|
||||
@ -38,7 +38,7 @@ public class InfoCommand implements CommandExec {
|
||||
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60);
|
||||
int guildCount = 0;
|
||||
int userCount = 0;
|
||||
for(JDA jda: Rixa.getInstance().getShardsList()) {
|
||||
for(JDA jda: Rixa.getShardsList()) {
|
||||
guildCount += jda.getGuilds().size();
|
||||
userCount += jda.getUsers().size();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class MusicCommand implements CommandExec {
|
||||
|
||||
public final int DEFAULT_VOLUME = 35; //(0 - 150, where 100 is default max volume)
|
||||
private final int DEFAULT_VOLUME = 35; //(0 - 150, where 100 is default max volume)
|
||||
private final AudioPlayerManager playerManager;
|
||||
private final Map<String, MusicManager> musicManagers;
|
||||
public MusicCommand() {
|
||||
@ -216,18 +216,20 @@ public class MusicCommand implements CommandExec {
|
||||
} else if (message.length == 3) {
|
||||
if(message[1].equalsIgnoreCase("join")) {
|
||||
VoiceChannel chan = null;
|
||||
if (guild.getVoiceChannelsByName(message[2], true).size() >= 1) {
|
||||
chan = guild.getVoiceChannelsByName(message[2], true).get(0);
|
||||
String channelName = message[2];//getMessage(message, 2).trim();
|
||||
if (guild.getVoiceChannelsByName(channelName, true).size() >= 1) {
|
||||
chan = guild.getVoiceChannelsByName(channelName, true).get(0);
|
||||
} else {
|
||||
for (VoiceChannel voiceChannel : guild.getVoiceChannels()) {
|
||||
if (voiceChannel.getName().contains(message[2]) || voiceChannel.getId().equalsIgnoreCase(message[2])) {
|
||||
if (voiceChannel.getName().contains(channelName) || voiceChannel.getName().equalsIgnoreCase(channelName) ||
|
||||
voiceChannel.getId().equalsIgnoreCase(channelName)) {
|
||||
chan = voiceChannel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chan == null) {
|
||||
new MessageBuilder("Sorry I was unable to find the VoiceChannel: `" + message[2] + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
new MessageBuilder("Sorry I was unable to find the VoiceChannel: `" + channelName + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else {
|
||||
guild.getAudioManager().setSendingHandler(mng.sendHandler);
|
||||
try {
|
||||
@ -271,7 +273,8 @@ public class MusicCommand implements CommandExec {
|
||||
chan = guild.getVoiceChannelsByName(channelName, true).get(0);
|
||||
} else {
|
||||
for (VoiceChannel voiceChannel : guild.getVoiceChannels()) {
|
||||
if (voiceChannel.getName().contains(channelName) || voiceChannel.getId().equalsIgnoreCase(channelName)) {
|
||||
if (voiceChannel.getName().contains(channelName) || voiceChannel.getId().equalsIgnoreCase(channelName)
|
||||
|| voiceChannel.getName().equalsIgnoreCase(channelName)) {
|
||||
chan = voiceChannel;
|
||||
break;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class UrbanDictionaryCommand implements CommandExec {
|
||||
channelType = ChannelType.TEXT)
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
String[] message = event.getMessage().getContent().split(" ");
|
||||
String search = getMessage(message, 1);
|
||||
String search = getMessage(message);
|
||||
UrbanDictionary ud = null;
|
||||
try {
|
||||
ud = new UrbanDictionary(URLEncoder.encode(search, "UTF-8"));
|
||||
@ -45,9 +45,9 @@ public class UrbanDictionaryCommand implements CommandExec {
|
||||
.addThumbnail("https://s-media-cache-ak0.pinimg.com/originals/f2/aa/37/f2aa3712516cfd0cf6f215301d87a7c2.jpg").queue(event.getChannel());
|
||||
}
|
||||
|
||||
private String getMessage(String[] messages, int argToBegin) {
|
||||
private String getMessage(String[] messages) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(int i = argToBegin; i < messages.length; i++) {
|
||||
for(int i = 1; i < messages.length; i++) {
|
||||
builder.append(messages[i]).append(" ");
|
||||
}
|
||||
return builder.toString().trim();
|
||||
|
@ -21,7 +21,7 @@ public class YoutubeCommand implements CommandExec {
|
||||
channelType = ChannelType.TEXT)
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
String[] message = event.getMessage().getContent().split(" ");
|
||||
String search = getMessage(message, 1);
|
||||
String search = getMessage(message);
|
||||
try {
|
||||
YoutubeSearch ytSearch = new YoutubeSearch(search);
|
||||
new MessageBuilder(ytSearch.getUrl(0))
|
||||
@ -31,9 +31,9 @@ public class YoutubeCommand implements CommandExec {
|
||||
}
|
||||
}
|
||||
|
||||
private String getMessage(String[] messages, int argToBegin) {
|
||||
private String getMessage(String[] messages) {
|
||||
StringBuilder builder = new StringBuilder() ;
|
||||
for(int i = argToBegin; i < messages.length; i++) {
|
||||
for(int i = 1; i < messages.length; i++) {
|
||||
builder.append(messages[i]).append(" ");
|
||||
}
|
||||
return builder.toString().trim();
|
||||
|
@ -7,5 +7,5 @@ import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
*/
|
||||
public interface CommandExec {
|
||||
|
||||
public void execute(GuildMessageReceivedEvent event);
|
||||
void execute(GuildMessageReceivedEvent event);
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ package me.savvy.rixa.commands.handlers;
|
||||
* Created by Timber on 5/22/2017.
|
||||
*/
|
||||
public enum CommandType {
|
||||
USER, MOD, ADMIN, BOT_OWNER;
|
||||
USER, MOD, ADMIN, BOT_OWNER
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class Data {
|
||||
private DatabaseManager db;
|
||||
public Data(DataType dataType) {
|
||||
this.dataType = dataType;
|
||||
this.db = Rixa.getInstance().getDbManager();
|
||||
this.db = Rixa.getDbManager();
|
||||
}
|
||||
|
||||
public Object get(String key, String value, String objToGet, String table) throws SQLException {
|
||||
@ -64,7 +64,11 @@ public class Data {
|
||||
public Result exists(String check) {
|
||||
switch(dataType) {
|
||||
case SQL:
|
||||
try {
|
||||
return db.checkExists(check);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Result.FALSE;
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ package me.savvy.rixa.data.database;
|
||||
public enum DataType {
|
||||
|
||||
SQL,
|
||||
FLAT_FILE;
|
||||
FLAT_FILE
|
||||
}
|
||||
|
@ -11,8 +11,9 @@ import java.sql.SQLException;
|
||||
|
||||
public class DatabaseManager {
|
||||
|
||||
private Connection connection = null;
|
||||
private Connection connection;
|
||||
private MySQL MYSQL = null;
|
||||
|
||||
public DatabaseManager(String hostName, String port, String databaseName, String userName, String password) {
|
||||
MYSQL = new MySQL(hostName, port, databaseName, userName, password);
|
||||
}
|
||||
@ -22,16 +23,12 @@ public class DatabaseManager {
|
||||
}
|
||||
|
||||
public void createTable() {
|
||||
try {
|
||||
connection = MYSQL.openConnection();
|
||||
Rixa.getInstance().getLogger().info("Mysql database connected");
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
checkConnection();
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(
|
||||
"CREATE TABLE IF NOT EXISTS `core` (`guild_id` varchar(255) NOT NULL, `guild_name` varchar(255) NOT NULL, PRIMARY KEY (`guild_id`));");
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
Rixa.getInstance().getLogger().severe("Could not check if table exists, stopping server.");
|
||||
e.printStackTrace();
|
||||
@ -41,20 +38,21 @@ public class DatabaseManager {
|
||||
|
||||
private void checkConnection() {
|
||||
try {
|
||||
if(!MYSQL.checkConnection()) {
|
||||
if (!MYSQL.checkConnection()) {
|
||||
connection = MYSQL.openConnection();
|
||||
Rixa.getInstance().getLogger().info("Mysql database connected");
|
||||
}
|
||||
} catch(ClassNotFoundException | SQLException e) {
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Result executeUpdate(PreparedStatement ps) {
|
||||
public Result executeUpdate(PreparedStatement ps) throws SQLException {
|
||||
checkConnection();
|
||||
try {
|
||||
ps.executeUpdate();
|
||||
return Result.SUCCESS;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return Result.ERROR;
|
||||
}
|
||||
@ -74,7 +72,7 @@ public class DatabaseManager {
|
||||
public ResultSet getObject(PreparedStatement ps) throws SQLException {
|
||||
checkConnection();
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if(rs.next()) {
|
||||
if (rs.next()) {
|
||||
return rs;
|
||||
}
|
||||
return null;
|
||||
@ -93,28 +91,29 @@ public class DatabaseManager {
|
||||
|
||||
public int getCount(String table) {
|
||||
checkConnection();
|
||||
ResultSet rs;
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement("SELECT count(*) FROM '" + table + "';");
|
||||
rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
return rs.getInt(1);
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT count(*) FROM '" + table + "';");
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
preparedStatement.close();
|
||||
resultSet.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Result checkExists(String string) {
|
||||
public Result checkExists(String string) throws SQLException {
|
||||
checkConnection();
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(string);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if(rs.next()) {
|
||||
if (rs.next()) {
|
||||
rs.close();
|
||||
return Result.TRUE;
|
||||
}else {
|
||||
} else {
|
||||
rs.close();
|
||||
return Result.FALSE;
|
||||
}
|
||||
@ -123,12 +122,13 @@ public class DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Result insert(String string) {
|
||||
checkConnection();
|
||||
PreparedStatement ps;
|
||||
try {
|
||||
ps = connection.prepareStatement(string);
|
||||
ps.executeUpdate();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(string);
|
||||
preparedStatement.executeUpdate();
|
||||
preparedStatement.close();
|
||||
return Result.SUCCESS;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -36,7 +36,7 @@ public abstract class Database {
|
||||
* @throws ClassNotFoundException
|
||||
* if the driver cannot be found
|
||||
*/
|
||||
public abstract Connection openConnection() throws SQLException,
|
||||
protected abstract Connection openConnection() throws SQLException,
|
||||
ClassNotFoundException;
|
||||
|
||||
/**
|
||||
@ -88,9 +88,7 @@ public abstract class Database {
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
|
||||
ResultSet result = statement.executeQuery(query);
|
||||
|
||||
return result;
|
||||
return statement.executeQuery(query);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,8 +112,6 @@ public abstract class Database {
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
|
||||
int result = statement.executeUpdate(query);
|
||||
|
||||
return result;
|
||||
return statement.executeUpdate(query);
|
||||
}
|
||||
}
|
@ -3,5 +3,5 @@ package me.savvy.rixa.data.placeholder;
|
||||
/**
|
||||
* Created by Timber on 6/4/2017.
|
||||
*/
|
||||
public class PlaceHolder {
|
||||
class PlaceHolder {
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ public enum Result {
|
||||
SUCCESS,
|
||||
TRUE,
|
||||
FALSE,
|
||||
ERROR;
|
||||
ERROR
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public class MessageEvent {
|
||||
@SubscribeEvent
|
||||
public void handle(GuildMessageReceivedEvent event) {
|
||||
if (event.getGuild() == null) return;
|
||||
if (event.getAuthor().isBot()) return;
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
String prefix = rixaGuild
|
||||
.getGuildSettings()
|
||||
|
@ -60,7 +60,12 @@ public class RixaGuild {
|
||||
}
|
||||
|
||||
private boolean checkExists() {
|
||||
Result r = Rixa.getDbManager().checkExists("SELECT `guild_name` FROM `core` WHERE `guild_id` = '" + guild.getId() + "';");
|
||||
Result r = Result.ERROR;
|
||||
try {
|
||||
r = Rixa.getDbManager().checkExists("SELECT `guild_name` FROM `core` WHERE `guild_id` = '" + guild.getId() + "';");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return r == Result.TRUE;
|
||||
}
|
||||
|
||||
@ -141,7 +146,7 @@ public class RixaGuild {
|
||||
@Getter
|
||||
private static Map<String, RixaGuild> guilds = new HashMap<>();
|
||||
|
||||
public static void addGuild(RixaGuild guild) {
|
||||
private static void addGuild(RixaGuild guild) {
|
||||
if(check(guild.getGuild())) return;
|
||||
guilds.put(guild.getGuild().getId(), guild);
|
||||
}
|
||||
|
@ -34,16 +34,16 @@ public class GuildSettings {
|
||||
|
||||
private void load() throws SQLException {
|
||||
if(!checkExists()) {
|
||||
Rixa.getInstance().getDbManager().insert("INSERT INTO `settings` (`guild_id`, `log_enabled`, `log_channel`, `joinMessage`, `quitMessage`, `greetings`, `farewell`," +
|
||||
Rixa.getDbManager().insert("INSERT INTO `settings` (`guild_id`, `log_enabled`, `log_channel`, `joinMessage`, `quitMessage`, `greetings`, `farewell`," +
|
||||
" `prefix`, `joinPm`, `joinVerification`, `defaultRole`, `muteRole`)" +
|
||||
" VALUES ('" + guild.getId() + "', '0', 'default_value', 'default_value', 'default_value', 'default_value', 'default_value', '/'," +
|
||||
" 'default', '0', 'default_value', 'default_value');");
|
||||
return;
|
||||
}
|
||||
PreparedStatement ps = Rixa.getInstance().getDbManager()
|
||||
PreparedStatement ps = Rixa.getDbManager()
|
||||
.getConnection().prepareStatement("SELECT * FROM `settings` WHERE `guild_id` = ?");
|
||||
ps.setString(1, guild.getId());
|
||||
ResultSet set = Rixa.getInstance().getDbManager().getObject(ps);
|
||||
ResultSet set = Rixa.getDbManager().getObject(ps);
|
||||
this.prefix = (set.getString("prefix"));
|
||||
this.defaultRole = (set.getString("defaultRole"));
|
||||
this.joinMessage = (set.getString("joinMessage"));
|
||||
@ -57,16 +57,21 @@ public class GuildSettings {
|
||||
if(!set.getString("farewell").equalsIgnoreCase("default_value")) {
|
||||
quitMessageChannel = guild.getTextChannelById(set.getString("farewell"));
|
||||
}
|
||||
ps = Rixa.getInstance().getDbManager()
|
||||
ps = Rixa.getDbManager()
|
||||
.getConnection().prepareStatement("SELECT * FROM `core` WHERE `guild_id` = ?");
|
||||
ps.setString(1, guild.getId());
|
||||
set = Rixa.getInstance().getDbManager().getObject(ps);
|
||||
set = Rixa.getDbManager().getObject(ps);
|
||||
this.description = (set.getString("description"));
|
||||
this.enlisted = (set.getBoolean("enlisted"));
|
||||
}
|
||||
|
||||
private boolean checkExists() {
|
||||
return Rixa.getInstance().getDbManager().checkExists("SELECT `guild_id` FROM `settings` WHERE `guild_id` = '" + guild.getId() + "'") == Result.TRUE;
|
||||
try {
|
||||
return Rixa.getDbManager().checkExists("SELECT `guild_id` FROM `settings` WHERE `guild_id` = '" + guild.getId() + "'") == Result.TRUE;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
@ -75,56 +80,56 @@ public class GuildSettings {
|
||||
|
||||
public void setJoinMessage(String joinMessage) {
|
||||
this.joinMessage = joinMessage;
|
||||
Rixa.getInstance().getData().update("settings", "joinMessage", "guild_id", joinMessage, guild.getId());
|
||||
Rixa.getData().update("settings", "joinMessage", "guild_id", joinMessage, guild.getId());
|
||||
}
|
||||
|
||||
public void setQuitMessage(String quitMessage) {
|
||||
this.quitMessage = quitMessage;
|
||||
Rixa.getInstance().getData().update("settings", "quitMessage", "guild_id", quitMessage, guild.getId());
|
||||
Rixa.getData().update("settings", "quitMessage", "guild_id", quitMessage, guild.getId());
|
||||
}
|
||||
|
||||
public void setJoinPrivateMessage(String joinPrivateMessage) {
|
||||
this.joinPrivateMessage = joinPrivateMessage;
|
||||
Rixa.getInstance().getData().update("settings", "joinPM", "guild_id", joinPrivateMessage, guild.getId());
|
||||
Rixa.getData().update("settings", "joinPM", "guild_id", joinPrivateMessage, guild.getId());
|
||||
}
|
||||
|
||||
public void setJoinMessageChannel(TextChannel joinMessageChannel) {
|
||||
this.joinMessageChannel = joinMessageChannel;
|
||||
Rixa.getInstance().getData().update("settings", "greetings", "guild_id", joinMessageChannel.getId(), guild.getId());
|
||||
Rixa.getData().update("settings", "greetings", "guild_id", joinMessageChannel.getId(), guild.getId());
|
||||
}
|
||||
|
||||
public void setQuitMessageChannel(TextChannel quitMessageChannel) {
|
||||
this.quitMessageChannel = quitMessageChannel;
|
||||
Rixa.getInstance().getData().update("settings", "farewell", "guild_id", quitMessageChannel.getId(), guild.getId());
|
||||
Rixa.getData().update("settings", "farewell", "guild_id", quitMessageChannel.getId(), guild.getId());
|
||||
}
|
||||
|
||||
public void setDefaultRole(String defaultRole) {
|
||||
this.defaultRole = defaultRole;
|
||||
Rixa.getInstance().getData().update("settings", "defaultRole", "guild_id", defaultRole, guild.getId());
|
||||
Rixa.getData().update("settings", "defaultRole", "guild_id", defaultRole, guild.getId());
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
Rixa.getInstance().getData().update("settings", "prefix", "guild_id", prefix, guild.getId());
|
||||
Rixa.getData().update("settings", "prefix", "guild_id", prefix, guild.getId());
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
Rixa.getInstance().getData().update("core", "description", "guild_id", description, guild.getId());
|
||||
Rixa.getData().update("core", "description", "guild_id", description, guild.getId());
|
||||
}
|
||||
|
||||
public void setEnlisted(boolean enlisted) {
|
||||
this.enlisted = enlisted;
|
||||
Rixa.getInstance().getData().update("core", "enlisted", "guild_id", enlisted, guild.getId());
|
||||
Rixa.getData().update("core", "enlisted", "guild_id", enlisted, guild.getId());
|
||||
}
|
||||
|
||||
public void setMuteRole(String muteRole) {
|
||||
this.muteRole = muteRole;
|
||||
Rixa.getInstance().getData().update("settings", "muteRole", "guild_id", muteRole, guild.getId());
|
||||
Rixa.getData().update("settings", "muteRole", "guild_id", muteRole, guild.getId());
|
||||
}
|
||||
|
||||
public void setJoinVerification(boolean joinVerification) {
|
||||
this.joinVerification = joinVerification;
|
||||
Rixa.getInstance().getData().update("settings", "joinVerification", "guild_id", joinVerification, guild.getId());
|
||||
Rixa.getData().update("settings", "joinVerification", "guild_id", joinVerification, guild.getId());
|
||||
}
|
||||
}
|
||||
|
@ -104,9 +104,15 @@ public class UserData {
|
||||
|
||||
private boolean checkExists() {
|
||||
String query = "SELECT `%s` FROM `%s` WHERE `%s` = '%s' AND `%s` = '%s';";
|
||||
Result r = Rixa.getDbManager().checkExists(String.format
|
||||
Result r;
|
||||
try {
|
||||
r = Rixa.getDbManager().checkExists(String.format
|
||||
(query, "user_id", "levels", "guild_id", guild.getId(), "user_id", user.getId()));
|
||||
return r == Result.TRUE;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void insert() {
|
||||
@ -115,7 +121,7 @@ public class UserData {
|
||||
.insert(String.format(query, "levels", "guild_id", "user_id", "experience", guild.getId(), user.getId(), 0));
|
||||
}
|
||||
|
||||
public void setExperience(int experience) {
|
||||
private void setExperience(int experience) {
|
||||
this.experience = experience;
|
||||
String query = "UPDATE `%s` SET `%s` = '%s' WHERE `%s` = '%s' AND `%s` = '%s';";
|
||||
try {
|
||||
@ -129,7 +135,7 @@ public class UserData {
|
||||
}
|
||||
}
|
||||
|
||||
public int getRandom() {
|
||||
private int getRandom() {
|
||||
int i = random.nextInt(25);
|
||||
return (i > 15 && i < 25 ? i : getRandom());
|
||||
}
|
||||
|
@ -83,8 +83,13 @@ public class LevelsModule implements RixaModule {
|
||||
|
||||
private boolean checkExists() {
|
||||
String query = "SELECT `%s` FROM `%s` WHERE `%s` = '%s';";
|
||||
Result r = Rixa.getDbManager().checkExists(String.format
|
||||
Result r = Result.ERROR;
|
||||
try {
|
||||
r = Rixa.getDbManager().checkExists(String.format
|
||||
(query, "guild_id", "modules", "guild_id", rixaGuild.getGuild().getId()));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return r == Result.TRUE;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class MusicModule implements RixaModule {
|
||||
this.guild = guild;
|
||||
this.enabled = false;
|
||||
this.musicRole = "default_value";
|
||||
db = Rixa.getInstance().getDbManager();
|
||||
db = Rixa.getDbManager();
|
||||
load();
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class MusicModule implements RixaModule {
|
||||
|
||||
public Result setEnabled(boolean val) {
|
||||
this.enabled = val;
|
||||
return Rixa.getInstance().getData().update("music", "enabled", "guild_id", val, guild.getId());
|
||||
return Rixa.getData().update("music", "enabled", "guild_id", val, guild.getId());
|
||||
}
|
||||
|
||||
public boolean isRoleRequired() {
|
||||
@ -71,12 +71,17 @@ public class MusicModule implements RixaModule {
|
||||
|
||||
public Result setRole(String newRole) {
|
||||
this.musicRole = newRole;
|
||||
return Rixa.getInstance().getData().update("music", "music_role", "guild_id", newRole, guild.getId());
|
||||
return Rixa.getData().update("music", "music_role", "guild_id", newRole, guild.getId());
|
||||
}
|
||||
|
||||
public boolean checkExists() {
|
||||
Result r = Rixa.getInstance().getDbManager().checkExists("SELECT `guild_id` FROM `music` WHERE `guild_id` = '" +
|
||||
Result r = Result.ERROR;
|
||||
try {
|
||||
r = Rixa.getDbManager().checkExists("SELECT `guild_id` FROM `music` WHERE `guild_id` = '" +
|
||||
guild.getId() + "';");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return r == Result.TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,5 @@ import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent;
|
||||
*/
|
||||
public interface React {
|
||||
|
||||
public void reactionTrigger(MessageReactionAddEvent event);
|
||||
void reactionTrigger(MessageReactionAddEvent event);
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ public class YoutubeSearch {
|
||||
|
||||
private static final String API_KEY;
|
||||
private JSONArray items;
|
||||
private final String YOUTUBE_WATCH_BASE_URL = "https://www.youtube.com/watch?v=";
|
||||
|
||||
static {
|
||||
API_KEY = "AIzaSyD1wjRGbzKgvjqAU25pREy1dVio9WpcuS0";
|
||||
@ -83,6 +82,7 @@ public class YoutubeSearch {
|
||||
}
|
||||
|
||||
public String getUrl(int index) {
|
||||
String YOUTUBE_WATCH_BASE_URL = "https://www.youtube.com/watch?v=";
|
||||
return YOUTUBE_WATCH_BASE_URL + getVideoId(index);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user