More object oriented programming
This commit is contained in:
		@@ -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_144\\bin\\javac.exe'
 | 
			
		||||
compileJava.options.forkOptions.executable = 'C:\\Program Files\\Java\\jdk1.8.0_131\\bin\\javac.exe'
 | 
			
		||||
@@ -26,7 +26,6 @@ public class Database {
 | 
			
		||||
    private String database;
 | 
			
		||||
 | 
			
		||||
    private int port = 3306;
 | 
			
		||||
    private int timeout = 60 * 1000;
 | 
			
		||||
 | 
			
		||||
    private HikariDataSource source;
 | 
			
		||||
    private HikariConfig config = new HikariConfig();
 | 
			
		||||
@@ -49,6 +48,8 @@ public class Database {
 | 
			
		||||
        this.config.setUsername(this.username = username);
 | 
			
		||||
        this.config.setPassword(this.password = password);
 | 
			
		||||
        this.source = new HikariDataSource(config);
 | 
			
		||||
        this.source.setPoolName("rixa");
 | 
			
		||||
        this.source.setMaximumPoolSize(400);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -61,15 +62,6 @@ public class Database {
 | 
			
		||||
        return new DatabaseOptions();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Connects to the database
 | 
			
		||||
     *
 | 
			
		||||
     * @return Whether it connected or not
 | 
			
		||||
     * @since 1.0.0
 | 
			
		||||
     */
 | 
			
		||||
    public void init() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sends a query to the database
 | 
			
		||||
     *
 | 
			
		||||
@@ -88,7 +80,7 @@ public class Database {
 | 
			
		||||
                return Optional.of(preparedStatement.executeUpdate());
 | 
			
		||||
            }
 | 
			
		||||
        } catch (SQLException exception) {
 | 
			
		||||
            exception.printStackTrace();
 | 
			
		||||
            System.out.println("INFO: Couldn't send update / query! : " + exception.getLocalizedMessage());
 | 
			
		||||
            return Optional.empty();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -106,7 +98,7 @@ public class Database {
 | 
			
		||||
            }
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            // Can't handle closing statement
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            System.out.println("INFO: Close connection! : " + e.getLocalizedMessage());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -119,7 +111,7 @@ public class Database {
 | 
			
		||||
     */
 | 
			
		||||
    public Optional<PreparedStatement> prepare(Statement statement) {
 | 
			
		||||
        try {
 | 
			
		||||
            PreparedStatement preparedStatement = source.getConnection().prepareStatement(statement.getSQL());
 | 
			
		||||
            PreparedStatement preparedStatement = getConnection().get().prepareStatement(statement.getSQL());
 | 
			
		||||
            for (Map.Entry<Integer, Parameter> parameter : statement.getParameters().entrySet()) {
 | 
			
		||||
                switch (parameter.getValue().getType()) {
 | 
			
		||||
                    case STRING:
 | 
			
		||||
@@ -156,7 +148,7 @@ public class Database {
 | 
			
		||||
            }
 | 
			
		||||
            return Optional.of(preparedStatement);
 | 
			
		||||
        } catch (SQLException exception) {
 | 
			
		||||
            exception.printStackTrace();
 | 
			
		||||
            System.out.println("INFO: Couldn't prepare statement : " + exception.getLocalizedMessage());
 | 
			
		||||
            return Optional.empty();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -172,7 +164,7 @@ public class Database {
 | 
			
		||||
        try {
 | 
			
		||||
            return Optional.of(source.getConnection().prepareStatement(sql));
 | 
			
		||||
        } catch (SQLException exception) {
 | 
			
		||||
            exception.printStackTrace();
 | 
			
		||||
            System.out.println("INFO: Couldn't send update / query! : " + exception.getLocalizedMessage());
 | 
			
		||||
            return Optional.empty();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -187,6 +179,7 @@ public class Database {
 | 
			
		||||
        try {
 | 
			
		||||
            return Optional.of(source.getConnection());
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            System.out.println("INFO: Couldn't get connection : " + e.getLocalizedMessage());
 | 
			
		||||
            return Optional.empty();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
package me.majrly.database;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Apart of the database api to manage all your databases
 | 
			
		||||
 *
 | 
			
		||||
 * @author Majrly
 | 
			
		||||
 * @since 1.0.0
 | 
			
		||||
 */
 | 
			
		||||
public class DatabaseManager {
 | 
			
		||||
 | 
			
		||||
    private static HashMap<String, Database> databases = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add a database to {@link #databases}
 | 
			
		||||
     *
 | 
			
		||||
     * @param database The database you want to add
 | 
			
		||||
     * @since 1.0.0
 | 
			
		||||
     */
 | 
			
		||||
    public static void addDatabase(Database database) {
 | 
			
		||||
        databases.put(database.getName(), database);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a database with specified name from {@link #databases}
 | 
			
		||||
     *
 | 
			
		||||
     * @param name The name of the database you want to obtain
 | 
			
		||||
     * @return The database wrapper
 | 
			
		||||
     * @since 1.0.0
 | 
			
		||||
     */
 | 
			
		||||
    public static Database getDatabase(String name) {
 | 
			
		||||
        return databases.get(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Getters
 | 
			
		||||
    public static HashMap<String, Database> getDatabases() {
 | 
			
		||||
        return databases;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -25,7 +25,9 @@ import me.savvy.rixa.data.filemanager.LanguageManager;
 | 
			
		||||
import me.savvy.rixa.events.BotEvent;
 | 
			
		||||
import me.savvy.rixa.events.MemberEvent;
 | 
			
		||||
import me.savvy.rixa.events.MessageEvent;
 | 
			
		||||
import me.savvy.rixa.events.Shutdown;
 | 
			
		||||
import me.savvy.rixa.events.VoiceChannel;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.React;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.ReactionManager;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.react.ConfigReaction;
 | 
			
		||||
@@ -38,6 +40,7 @@ import net.dv8tion.jda.core.OnlineStatus;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Game;
 | 
			
		||||
import net.dv8tion.jda.core.exceptions.RateLimitedException;
 | 
			
		||||
import net.dv8tion.jda.core.hooks.AnnotatedEventManager;
 | 
			
		||||
import net.dv8tion.jda.core.requests.Route;
 | 
			
		||||
 | 
			
		||||
import javax.security.auth.login.LoginException;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
@@ -65,9 +68,6 @@ public class Rixa {
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private static Database database;
 | 
			
		||||
    private static ChatterBotFactory factory;
 | 
			
		||||
    private static ChatterBotSession chatBotSession;
 | 
			
		||||
    private static ChatterBot chatBot;
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private LanguageManager languageManager;
 | 
			
		||||
@@ -75,17 +75,28 @@ public class Rixa {
 | 
			
		||||
    @Setter
 | 
			
		||||
    private ScheduledExecutorService executorService;
 | 
			
		||||
 | 
			
		||||
    private static ChatterBotFactory factory;
 | 
			
		||||
    private static ChatterBotSession chatBotSession;
 | 
			
		||||
    private static ChatterBot chatBot;
 | 
			
		||||
 | 
			
		||||
    // String search = event.getMessage().getContent().substring(event.getMessage().getContent().indexOf(" ") + 1);
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        instance = new Rixa();
 | 
			
		||||
        shardsList = new LinkedList<>();
 | 
			
		||||
        //    config = new ConfigManager();
 | 
			
		||||
        config = new ConfigManager(new File("Rixa/config.json"));
 | 
			
		||||
        load();
 | 
			
		||||
 | 
			
		||||
        Runtime.getRuntime().addShutdownHook(new Thread() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                getShardsList().forEach(JDA::shutdown);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void load() {
 | 
			
		||||
        getInstance().setExecutorService(Executors.newSingleThreadScheduledExecutor());
 | 
			
		||||
 | 
			
		||||
        database = Database.options()
 | 
			
		||||
                .type("mysql")
 | 
			
		||||
                .hostname(String.valueOf(config.getJsonObject().getJSONObject("sql").getString("hostName")), config.getJsonObject().getJSONObject("sql").getInt("portNumber"))
 | 
			
		||||
@@ -97,6 +108,7 @@ public class Rixa {
 | 
			
		||||
            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;
 | 
			
		||||
@@ -109,6 +121,7 @@ public class Rixa {
 | 
			
		||||
                        .addEventListener(new BotEvent())
 | 
			
		||||
                        .addEventListener(new MemberEvent())
 | 
			
		||||
                        .addEventListener(new VoiceChannel())
 | 
			
		||||
                        .addEventListener(new Shutdown())
 | 
			
		||||
                        .setGame(Game.of(config.getJsonObject().getString("botGame")))
 | 
			
		||||
                        .setAutoReconnect(true)
 | 
			
		||||
                        .setStatus(OnlineStatus.ONLINE)
 | 
			
		||||
@@ -120,15 +133,17 @@ public class Rixa {
 | 
			
		||||
        } catch (LoginException | InterruptedException | RateLimitedException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Guilds.getGuilds().values().parallelStream().forEach((rixaGuild) -> rixaGuild.load());
 | 
			
		||||
 | 
			
		||||
        timeUp = System.currentTimeMillis();
 | 
			
		||||
        register(new CommandExec[]{
 | 
			
		||||
                new InfoCommand(), new ServerInfoCommand(), new HelpCommand(),
 | 
			
		||||
        register(new InfoCommand(), new ServerInfoCommand(), new HelpCommand(),
 | 
			
		||||
                new DeleteMessagesCommand(), new PingCommand(), new PurgeMessagesCommand(),
 | 
			
		||||
                new BatchMoveCommand(), new MuteCommand(), new MusicCommand(),
 | 
			
		||||
                new ConfigCommand(), new UrbanDictionaryCommand(), new YoutubeCommand(),
 | 
			
		||||
                new AddRoleCommand(), new RemoveRoleCommand(), new LevelsCommand(),
 | 
			
		||||
                new LeaderboardCommand(), new RaidModeCommand()});
 | 
			
		||||
        register(new React[]{new HelpReaction(), new ConfigReaction(), new LeaderboardReaction()});
 | 
			
		||||
                new LeaderboardCommand(), new RaidModeCommand());
 | 
			
		||||
        register(new HelpReaction(), new ConfigReaction(), new LeaderboardReaction());
 | 
			
		||||
        try {
 | 
			
		||||
            factory = new ChatterBotFactory();
 | 
			
		||||
            chatBot = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
 | 
			
		||||
@@ -138,13 +153,13 @@ public class Rixa {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void register(CommandExec commandExecs[]) {
 | 
			
		||||
    private static void register(CommandExec... commandExecs) {
 | 
			
		||||
        for (CommandExec command : commandExecs) {
 | 
			
		||||
            CommandHandler.registerCommand(command);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void register(React react[]) {
 | 
			
		||||
    private static void register(React... react) {
 | 
			
		||||
        for (React reaction : react) {
 | 
			
		||||
            ReactionManager.registerReaction(reaction);
 | 
			
		||||
        }
 | 
			
		||||
@@ -159,10 +174,15 @@ public class Rixa {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void exit() {
 | 
			
		||||
        try {
 | 
			
		||||
            database.close();
 | 
			
		||||
        getShardsList().forEach(JDA::shutdown);
 | 
			
		||||
            Thread.sleep(5000);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void close() {
 | 
			
		||||
        try {
 | 
			
		||||
            Guilds.getGuilds().values().parallelStream().forEach((rixaGuild) -> rixaGuild.save());
 | 
			
		||||
            Thread.sleep(1200);
 | 
			
		||||
            database.close();
 | 
			
		||||
            Thread.sleep(200);
 | 
			
		||||
            System.exit(0);
 | 
			
		||||
        } catch (InterruptedException ex) {
 | 
			
		||||
            getLogger().severe("Could not shutdown Rixa instance.");
 | 
			
		||||
 
 | 
			
		||||
@@ -5,15 +5,13 @@ 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.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Role;
 | 
			
		||||
import net.dv8tion.jda.core.entities.TextChannel;
 | 
			
		||||
import net.dv8tion.jda.core.entities.User;
 | 
			
		||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
 | 
			
		||||
import net.dv8tion.jda.core.exceptions.PermissionException;
 | 
			
		||||
import net.dv8tion.jda.core.managers.GuildManager;
 | 
			
		||||
import net.dv8tion.jda.core.requests.restaction.InviteAction;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -28,7 +26,7 @@ public class AddRoleCommand implements CommandExec {
 | 
			
		||||
            channelType = ChannelType.TEXT,
 | 
			
		||||
            usage = "%paddrole", mainCommand = "addrole", aliases = {"ar", "addroles", "ars"})
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.ADD_ROLE)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import me.savvy.rixa.commands.handlers.Command;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandExec;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.RixaPermission;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
@@ -25,7 +26,7 @@ public class BatchMoveCommand implements CommandExec {
 | 
			
		||||
            description = "Move users within one role to another!",
 | 
			
		||||
            channelType = ChannelType.TEXT)
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
         RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
         RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.BATCH_MOVE)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,9 @@ 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.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.levels.LevelsModule;
 | 
			
		||||
import me.savvy.rixa.modules.music.MusicModule;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
@@ -55,7 +58,7 @@ public class ConfigCommand implements CommandExec {
 | 
			
		||||
            type = CommandType.ADMIN,
 | 
			
		||||
            channelType = ChannelType.TEXT)
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if (!rixaGuild.hasPermission(event.getMember(), RixaPermission.ACCESS_CONFIG)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.")
 | 
			
		||||
                    .setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
@@ -166,34 +169,34 @@ public class ConfigCommand implements CommandExec {
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                Role role = event.getMessage().getMentionedRoles().get(0);
 | 
			
		||||
                rixaGuild.getMusicModule().setRole(role.getId());
 | 
			
		||||
                ((MusicModule) rixaGuild.getModule("Music")).setMusicRole(role.getId());
 | 
			
		||||
                new MessageBuilder("Successfully set music role to " + role.getName() + "!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            }
 | 
			
		||||
        } else if (messages[1].equalsIgnoreCase("enable")) {
 | 
			
		||||
            if (messages[2].equalsIgnoreCase("music")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getMusicModule().setEnabled(true);
 | 
			
		||||
                ((MusicModule) rixaGuild.getModule("Music")).setEnabled(true);
 | 
			
		||||
                new MessageBuilder("Successfully enabled the music module!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            } else if (messages[2].equalsIgnoreCase("levels")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getLevelsModule().setEnabled(true);
 | 
			
		||||
                ((LevelsModule) rixaGuild.getModule("Levels")).setEnabled(true);
 | 
			
		||||
                event.getChannel().sendMessage("Successfully enabled the levels module").queue();
 | 
			
		||||
            } else if (messages[2].equalsIgnoreCase("joinverification")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(true);
 | 
			
		||||
                Guilds.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(true);
 | 
			
		||||
                new MessageBuilder("Successfully enabled Join Verification!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            }
 | 
			
		||||
        } else if (messages[1].equalsIgnoreCase("disable")) {
 | 
			
		||||
            if (messages[2].equalsIgnoreCase("music")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getMusicModule().setEnabled(false);
 | 
			
		||||
                ((MusicModule) rixaGuild.getModule("Music")).setEnabled(false);
 | 
			
		||||
                new MessageBuilder("Successfully disabled the music module!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            } else if (messages[2].equalsIgnoreCase("levels")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getLevelsModule().setEnabled(false);
 | 
			
		||||
                ((MusicModule) rixaGuild.getModule("Music")).setEnabled(false);
 | 
			
		||||
                event.getChannel().sendMessage("Successfully disabled the levels module").queue();
 | 
			
		||||
            } else if (messages[2].equalsIgnoreCase("joinverification")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(false);
 | 
			
		||||
                Guilds.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(false);
 | 
			
		||||
                new MessageBuilder("Successfully disabled Join Verification!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            } else if (messages[2].equalsIgnoreCase("joinmessage")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getGuildSettings().setJoinMessageChannel("default_value");
 | 
			
		||||
                Guilds.getGuild(event.getGuild()).getGuildSettings().setJoinMessageChannel("default_value");
 | 
			
		||||
            } else if (messages[2].equalsIgnoreCase("quitmessage")) {
 | 
			
		||||
                RixaGuild.getGuild(event.getGuild()).getGuildSettings().setQuitMessageChannel("default_value");
 | 
			
		||||
                Guilds.getGuild(event.getGuild()).getGuildSettings().setQuitMessageChannel("default_value");
 | 
			
		||||
            }
 | 
			
		||||
        } else if (messages[1].equalsIgnoreCase("addperm") || messages[1].equalsIgnoreCase("addpermission") || messages[1].equalsIgnoreCase("aperm")) {
 | 
			
		||||
            String permission = "notFound";
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ 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.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Role;
 | 
			
		||||
@@ -25,7 +26,7 @@ public class RemoveRoleCommand implements CommandExec {
 | 
			
		||||
            channelType = ChannelType.TEXT,
 | 
			
		||||
            usage = "%premoverole", mainCommand = "removerole", aliases = {"rr", "removeroles"})
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.REMOVE_ROLE)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ 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.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
 | 
			
		||||
@@ -20,7 +21,7 @@ public class RoleRewardsCommand implements CommandExec {
 | 
			
		||||
            usage = "%prolerewards", mainCommand = "rolerewards",
 | 
			
		||||
            aliases =  {"rolereward", "rw"})
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        String[] args = event.getMessage().getContent().split(" ");
 | 
			
		||||
 | 
			
		||||
        // ?rw <add/remove/list> [level] [role]
 | 
			
		||||
@@ -31,7 +32,7 @@ public class RoleRewardsCommand implements CommandExec {
 | 
			
		||||
                            setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                /*if (rixaGuild.getLevelsModule().getRoleRewards().containsKey(Integer.parseInt(args[2]))) {
 | 
			
		||||
                /*if (((LevelsModule)  rixaGuild.getModule("Levels")).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;
 | 
			
		||||
@@ -51,7 +52,7 @@ public class RoleRewardsCommand implements CommandExec {
 | 
			
		||||
                switch(args[1].toLowerCase()) {
 | 
			
		||||
                    case "list":
 | 
			
		||||
                        Map<Integer, String> rewards = new HashMap<>();
 | 
			
		||||
                       /* rixaGuild.getLevelsModule().getRoleRewards().forEach((integer, s) -> {
 | 
			
		||||
                       /* ((LevelsModule)  rixaGuild.getModule("Levels")).getRoleRewards().forEach((integer, s) -> {
 | 
			
		||||
 | 
			
		||||
                        });*/
 | 
			
		||||
                        break;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,10 +4,7 @@ import me.savvy.rixa.commands.handlers.Command;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandExec;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.TextChannel;
 | 
			
		||||
import net.dv8tion.jda.core.entities.User;
 | 
			
		||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
 | 
			
		||||
import net.dv8tion.jda.core.requests.restaction.InviteAction;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by savit on 7/14/2017.
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,6 @@ import me.savvy.rixa.commands.handlers.CommandExec;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandType;
 | 
			
		||||
import net.dv8tion.jda.core.EmbedBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.JDA;
 | 
			
		||||
import net.dv8tion.jda.core.audit.ActionType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
import net.dv8tion.jda.core.entities.MessageEmbed;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,8 @@ package me.savvy.rixa.commands.general;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.Command;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandExec;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.levels.LevelsModule;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Message;
 | 
			
		||||
@@ -16,13 +18,13 @@ public class LeaderboardCommand implements CommandExec {
 | 
			
		||||
            aliases = {"leaderboards", "levels"},
 | 
			
		||||
            channelType = ChannelType.TEXT)
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        if (!rixaGuild.getLevelsModule().isEnabled()) {
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if (!((LevelsModule) rixaGuild.getModule("Levels")).isEnabled()) {
 | 
			
		||||
            new MessageBuilder("Levels are not enabled on this server!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        Message message = event.getChannel().sendMessage
 | 
			
		||||
                (rixaGuild.getLevelsModule().leaderboard
 | 
			
		||||
                (((LevelsModule) rixaGuild.getModule("Levels")).leaderboard
 | 
			
		||||
                        (event.getMember(), 1).getBuilder().build()).complete();
 | 
			
		||||
        message.addReaction("\u2B05").complete();
 | 
			
		||||
                message.addReaction("\u27A1").complete();
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,9 @@ import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.Command;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandExec;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.guild.user.UserData;
 | 
			
		||||
import me.savvy.rixa.modules.levels.LevelsModule;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
@@ -24,8 +26,8 @@ public class LevelsCommand implements CommandExec {
 | 
			
		||||
            description = "View your levels!",
 | 
			
		||||
            channelType = ChannelType.TEXT)
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        if (!rixaGuild.getLevelsModule().isEnabled()) {
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if (!((LevelsModule)  rixaGuild.getModule("Levels")).isEnabled()) {
 | 
			
		||||
            new MessageBuilder("Levels are not enabled on this server!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -47,7 +49,7 @@ public class LevelsCommand implements CommandExec {
 | 
			
		||||
    
 | 
			
		||||
    public MessageBuilder getInfo(RixaGuild rixaGuild, Member member) {
 | 
			
		||||
        User author = member.getUser();
 | 
			
		||||
        UserData data = rixaGuild.getLevelsModule().getUserData(author.getId());
 | 
			
		||||
        UserData data = ((LevelsModule)  rixaGuild.getModule("Levels")).getUserData(author.getId());
 | 
			
		||||
        String query = "SELECT * FROM `levels` WHERE `guild_id` = '" + rixaGuild.getGuild().getId() + "' ORDER BY `experience` DESC";
 | 
			
		||||
        ResultSet rs = null;
 | 
			
		||||
        try {
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,9 @@ 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.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.music.MusicManager;
 | 
			
		||||
import me.savvy.rixa.modules.music.MusicModule;
 | 
			
		||||
import me.savvy.rixa.modules.music.TrackScheduler;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import me.savvy.rixa.utils.YoutubeSearch;
 | 
			
		||||
@@ -67,13 +69,14 @@ public class MusicCommand implements CommandExec {
 | 
			
		||||
            usage = "%pmusic", mainCommand = "music")
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        Guild guild = event.getGuild();
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(guild);
 | 
			
		||||
        if(!rixaGuild.getMusicModule().isEnabled()) {
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(guild);
 | 
			
		||||
        MusicModule module = ((MusicModule) rixaGuild.getModule("Music"));
 | 
			
		||||
        if(!module.isEnabled()) {
 | 
			
		||||
            new MessageBuilder("Sorry music is not enabled on `" + guild.getName() + "`!").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if(rixaGuild.getMusicModule().isRoleRequired()) {
 | 
			
		||||
            Role role = event.getGuild().getRoleById(rixaGuild.getMusicModule().getMusicRole());
 | 
			
		||||
        if(module.isRoleRequired()) {
 | 
			
		||||
            Role role = event.getGuild().getRoleById(module.getMusicRole());
 | 
			
		||||
            boolean hasRole = false;
 | 
			
		||||
            for (Role roleItem : event.getMember().getRoles()) {
 | 
			
		||||
                if (roleItem.getId().equalsIgnoreCase(role.getId())) {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,8 +6,6 @@ import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
 | 
			
		||||
 | 
			
		||||
import java.time.temporal.ChronoUnit;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by Timber on 5/23/2017.
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package me.savvy.rixa.commands.general;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.Command;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandExec;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import net.dv8tion.jda.core.EmbedBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.User;
 | 
			
		||||
@@ -20,7 +21,7 @@ public class ServerInfoCommand implements CommandExec {
 | 
			
		||||
    description = "Receive information about the server!",
 | 
			
		||||
    aliases = "sinfo", mainCommand = "serverinfo")
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        EmbedBuilder messageEmbed = new EmbedBuilder();
 | 
			
		||||
        User owner = event.getGuild().getOwner().getUser();
 | 
			
		||||
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss");
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ 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.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import me.savvy.rixa.utils.Utils;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
@@ -28,7 +29,7 @@ public class DeleteMessagesCommand implements CommandExec {
 | 
			
		||||
    type = CommandType.MOD,
 | 
			
		||||
    usage = "%pclear")
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.CLEAR_CHAT)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ 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.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
@@ -25,7 +26,7 @@ public class MuteCommand implements CommandExec {
 | 
			
		||||
            type = CommandType.MOD,
 | 
			
		||||
            channelType = ChannelType.TEXT)
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.MUTE)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ 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.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import me.savvy.rixa.utils.Utils;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
@@ -31,7 +32,7 @@ public class PurgeMessagesCommand implements CommandExec {
 | 
			
		||||
            type = CommandType.MOD,
 | 
			
		||||
            usage = "%ppurge")
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.CLEAR_CHAT)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import me.savvy.rixa.commands.handlers.Command;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandExec;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.RixaPermission;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
 | 
			
		||||
@@ -19,7 +20,7 @@ public class RaidModeCommand implements CommandExec {
 | 
			
		||||
            channelType = ChannelType.TEXT,
 | 
			
		||||
            aliases = {"raidmode", "trm", "toggleraid"})
 | 
			
		||||
    public void execute(GuildMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.TOGGLE_RAIDMODE)) {
 | 
			
		||||
            new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ 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.enums.Result;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ package me.savvy.rixa.data.database.sql.other;
 | 
			
		||||
 | 
			
		||||
public enum DatabaseTables {
 | 
			
		||||
 | 
			
		||||
    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," +
 | 
			
		||||
    CORE("CREATE TABLE IF NOT EXISTS `core` ( `guild_id` varchar(255) NOT NULL PRIMARY KEY, `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" +
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package me.savvy.rixa.events;
 | 
			
		||||
 | 
			
		||||
import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import net.dv8tion.jda.core.events.ReadyEvent;
 | 
			
		||||
import net.dv8tion.jda.core.events.guild.GuildJoinEvent;
 | 
			
		||||
import net.dv8tion.jda.core.events.guild.GuildLeaveEvent;
 | 
			
		||||
@@ -29,6 +30,6 @@ public class BotEvent {
 | 
			
		||||
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public void onQuit(GuildLeaveEvent event) {
 | 
			
		||||
        RixaGuild.removeGuild(RixaGuild.getGuild(event.getGuild()));
 | 
			
		||||
        Guilds.removeGuild(Guilds.getGuild(event.getGuild()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package me.savvy.rixa.events;
 | 
			
		||||
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.Permission;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Role;
 | 
			
		||||
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
 | 
			
		||||
@@ -22,7 +22,7 @@ public class MemberEvent {
 | 
			
		||||
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public void onMember(GuildMemberJoinEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
 | 
			
		||||
      /*  if (rixaGuild.getGuildSettings().isRaidMode()) {
 | 
			
		||||
            if(event.getGuild().getSelfMember().hasPermission(Permission.KICK_MEMBERS)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,12 @@
 | 
			
		||||
package me.savvy.rixa.events;
 | 
			
		||||
 | 
			
		||||
import com.google.code.chatterbotapi.ChatterBotFactory;
 | 
			
		||||
import com.mysql.jdbc.StringUtils;
 | 
			
		||||
import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandHandler;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandRegistrar;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.levels.LevelsModule;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.ReactRegistrar;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.ReactionManager;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
@@ -34,7 +35,7 @@ import java.util.regex.Pattern;
 | 
			
		||||
 */
 | 
			
		||||
public class MessageEvent {
 | 
			
		||||
 | 
			
		||||
    private final Pattern INVITE = Pattern.compile("discord(?:\\.gg|app.com\\/invite)\\/([A-Z0-9-]{2,16})",Pattern.CASE_INSENSITIVE);
 | 
			
		||||
    private final Pattern INVITE = Pattern.compile("discord(?:\\.gg|app.com\\/invite)\\/([A-Z0-9-]{2,16})", Pattern.CASE_INSENSITIVE);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
@@ -46,39 +47,41 @@ public class MessageEvent {
 | 
			
		||||
                ("@" + event.getGuild().getSelfMember().getEffectiveName())) {
 | 
			
		||||
            try {
 | 
			
		||||
                String s = event.getMessage().getContent().replace
 | 
			
		||||
                        ("@" + event.getGuild().getSelfMember().getEffectiveName()+ " ", "");
 | 
			
		||||
                        ("@" + event.getGuild().getSelfMember().getEffectiveName() + " ", "");
 | 
			
		||||
                if (s.isEmpty()) return;
 | 
			
		||||
                s = Rixa.getChatBotSession().think(s);
 | 
			
		||||
                if (s.isEmpty()) return;
 | 
			
		||||
                event.getChannel().sendMessage(s).queue();
 | 
			
		||||
                return;
 | 
			
		||||
            } catch (Exception ex) { ex.printStackTrace(); }
 | 
			
		||||
            } catch (Exception ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
 | 
			
		||||
        String prefix = rixaGuild
 | 
			
		||||
                .getGuildSettings()
 | 
			
		||||
                .getPrefix();
 | 
			
		||||
        //checkMessage(event.getMessage());
 | 
			
		||||
        if (!event.getMessage().getContent().startsWith(prefix)) {
 | 
			
		||||
            if (!(rixaGuild.getLevelsModule().isEnabled())) {
 | 
			
		||||
            if (!(((LevelsModule) rixaGuild.getModule("Levels")).isEnabled())) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            /*if(!event.getAuthor().getId().equalsIgnoreCase("202944101333729280") &&
 | 
			
		||||
                    !event.getAuthor().getId().equalsIgnoreCase("207322957075185665")) {
 | 
			
		||||
                return;
 | 
			
		||||
            }*/
 | 
			
		||||
            if(rixaGuild.getLevelsModule().getUserData(event.getAuthor().getId()).awardIfCan()) {
 | 
			
		||||
            if (((LevelsModule) rixaGuild.getModule("Levels")).getUserData(event.getAuthor().getId()).awardIfCan()) {
 | 
			
		||||
                new MessageBuilder(event.getAuthor().getAsMention() + " has leveled up to level " +
 | 
			
		||||
                        rixaGuild.getLevelsModule().getUserData(event.getAuthor().getId()).getLevel())
 | 
			
		||||
                        ((LevelsModule) rixaGuild.getModule("Levels")).getUserData(event.getAuthor().getId()).getLevel())
 | 
			
		||||
                        .setColor(event.getMember().getColor()).queue(event.getChannel());
 | 
			
		||||
            }
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        String[] splitContent = event.getMessage().getContent().replace(prefix, "").split(" ");
 | 
			
		||||
        if(!CommandHandler.hasCommand(splitContent[0])) {
 | 
			
		||||
        if (!CommandHandler.hasCommand(splitContent[0])) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        CommandRegistrar cmd = CommandHandler.get(splitContent[0]);
 | 
			
		||||
@@ -93,18 +96,19 @@ public class MessageEvent {
 | 
			
		||||
    private void checkMessage(Message message) {
 | 
			
		||||
        List<String> invites = new ArrayList<>();
 | 
			
		||||
        Matcher matcher = INVITE.matcher(message.getRawContent());
 | 
			
		||||
        while(matcher.find()) {
 | 
			
		||||
        while (matcher.find()) {
 | 
			
		||||
            invites.add(matcher.group(1));
 | 
			
		||||
        }
 | 
			
		||||
        if(invites.size() == 0) {
 | 
			
		||||
        if (invites.size() == 0) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        for(String inviteCode : invites) {
 | 
			
		||||
        for (String inviteCode : invites) {
 | 
			
		||||
            Invite invite = null;
 | 
			
		||||
            try {
 | 
			
		||||
                invite = Invite.resolve(message.getJDA(), inviteCode).complete();
 | 
			
		||||
            } catch(Exception e) {}
 | 
			
		||||
            if(invite !=null && !invite.getGuild().getId().equals(message.getGuild().getId())) {
 | 
			
		||||
            } catch (Exception e) {
 | 
			
		||||
            }
 | 
			
		||||
            if (invite != null && !invite.getGuild().getId().equals(message.getGuild().getId())) {
 | 
			
		||||
                new MessageBuilder(String.format("Advertising is not allowed, %s!",
 | 
			
		||||
                        message.getAuthor().getAsMention())).setColor(message.getMember().getColor()).queue(message.getTextChannel());
 | 
			
		||||
                message.delete().reason("Advertising is not allowed!").queue();
 | 
			
		||||
@@ -116,7 +120,7 @@ public class MessageEvent {
 | 
			
		||||
    public void onMemberJoin(PrivateMessageReceivedEvent event) {
 | 
			
		||||
        RixaGuild rixaGuild;
 | 
			
		||||
        if (MemberEvent.joinMembers.containsKey(event.getAuthor().getId())) {
 | 
			
		||||
            rixaGuild = RixaGuild.getGuild(MemberEvent.joinMembers.get(event.getAuthor().getId()));
 | 
			
		||||
            rixaGuild = Guilds.getGuild(MemberEvent.joinMembers.get(event.getAuthor().getId()));
 | 
			
		||||
            if (event.getMessage().getContent().equalsIgnoreCase("I agree") ||
 | 
			
		||||
                    event.getMessage().getContent().equalsIgnoreCase("I accept")
 | 
			
		||||
                    || event.getMessage().getContent().equalsIgnoreCase("Yes")) {
 | 
			
		||||
@@ -128,7 +132,7 @@ public class MessageEvent {
 | 
			
		||||
                        new MessageBuilder(String.format("You have been promoted on %s!", rixaGuild.getGuild().getName()))
 | 
			
		||||
                                .setColor(rixaGuild.getGuild().getMember(event.getAuthor()).getColor()).send(event.getAuthor());
 | 
			
		||||
                        rixaGuild.getGuildSettings().setLastJoin(System.currentTimeMillis());
 | 
			
		||||
                    } catch(PermissionException ex) {
 | 
			
		||||
                    } catch (PermissionException ex) {
 | 
			
		||||
                        new MessageBuilder(String.format("I do not have permission for %s in %s", ex.getPermission().getName(), rixaGuild.getGuild().getName()))
 | 
			
		||||
                                .setColor(Color.RED).send(rixaGuild.getGuild().getOwner().getUser());
 | 
			
		||||
                    }
 | 
			
		||||
@@ -142,7 +146,7 @@ public class MessageEvent {
 | 
			
		||||
                    MemberEvent.joinMembers.remove(event.getAuthor().getId());
 | 
			
		||||
                    rixaGuild.getGuild().getController().kick(rixaGuild.getGuild().getMember(event.getAuthor())).complete();
 | 
			
		||||
                } catch (PermissionException ex) {
 | 
			
		||||
                    if(ex.getPermission() == Permission.KICK_MEMBERS) {
 | 
			
		||||
                    if (ex.getPermission() == Permission.KICK_MEMBERS) {
 | 
			
		||||
                        new MessageBuilder(String.format("I do not have permission to kick %s from %s", event.getAuthor().getName(), rixaGuild.getGuild().getName()))
 | 
			
		||||
                                .setColor(Color.RED).send(rixaGuild.getGuild().getOwner().getUser());
 | 
			
		||||
                    } else {
 | 
			
		||||
@@ -152,7 +156,7 @@ public class MessageEvent {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if(!event.getAuthor().isBot())
 | 
			
		||||
            if (!event.getAuthor().isBot())
 | 
			
		||||
                new MessageBuilder("Private messages are currently disabled!").setColor(Color.RED).send(event.getAuthor());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -160,12 +164,12 @@ public class MessageEvent {
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public void onReact(MessageReactionAddEvent event) {
 | 
			
		||||
        Message message = event.getChannel().getMessageById(event.getMessageId()).complete();
 | 
			
		||||
        if(message == null || message.getEmbeds().size() != 1) return;
 | 
			
		||||
        if (message == null || message.getEmbeds().size() != 1) return;
 | 
			
		||||
        MessageEmbed embed = message.getEmbeds().get(0);
 | 
			
		||||
        if(StringUtils.isNullOrEmpty(embed.getTitle())) return;
 | 
			
		||||
        if (StringUtils.isNullOrEmpty(embed.getTitle())) return;
 | 
			
		||||
        String[] titleSplit = embed.getTitle().split(": ");
 | 
			
		||||
        if (titleSplit[0].equalsIgnoreCase("Leaderboard")) return;
 | 
			
		||||
        if(!ReactionManager.getReactions().containsKey(titleSplit[0])) return;
 | 
			
		||||
        if (!ReactionManager.getReactions().containsKey(titleSplit[0])) return;
 | 
			
		||||
 | 
			
		||||
        ReactRegistrar reactRegistrar = ReactionManager.getReactions().get(titleSplit[0]);
 | 
			
		||||
        Method m = reactRegistrar.getMethod();
 | 
			
		||||
@@ -181,12 +185,12 @@ public class MessageEvent {
 | 
			
		||||
        if (event.getGuild() == null) return;
 | 
			
		||||
        if (event.getUser().isBot()) return;
 | 
			
		||||
        Message message = event.getChannel().getMessageById(event.getMessageId()).complete();
 | 
			
		||||
        if(message == null || message.getEmbeds().size() != 1) return;
 | 
			
		||||
        if (message == null || message.getEmbeds().size() != 1) return;
 | 
			
		||||
        MessageEmbed embed = message.getEmbeds().get(0);
 | 
			
		||||
        if(StringUtils.isNullOrEmpty(embed.getTitle())) return;
 | 
			
		||||
        if (StringUtils.isNullOrEmpty(embed.getTitle())) return;
 | 
			
		||||
        String[] titleSplit = embed.getTitle().split(": ");
 | 
			
		||||
        System.out.println(Arrays.toString(titleSplit));
 | 
			
		||||
        if(ReactionManager.getReactions().containsKey(titleSplit[0])) {
 | 
			
		||||
        if (ReactionManager.getReactions().containsKey(titleSplit[0])) {
 | 
			
		||||
            ReactRegistrar reactRegistrar = ReactionManager.getReactions().get(titleSplit[0]);
 | 
			
		||||
            Method m = reactRegistrar.getMethod();
 | 
			
		||||
            try {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								src/main/java/me/savvy/rixa/events/Shutdown.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/main/java/me/savvy/rixa/events/Shutdown.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
package me.savvy.rixa.events;
 | 
			
		||||
 | 
			
		||||
import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import net.dv8tion.jda.core.events.ReadyEvent;
 | 
			
		||||
import net.dv8tion.jda.core.events.ShutdownEvent;
 | 
			
		||||
import net.dv8tion.jda.core.events.guild.GuildJoinEvent;
 | 
			
		||||
import net.dv8tion.jda.core.events.guild.GuildLeaveEvent;
 | 
			
		||||
import net.dv8tion.jda.core.hooks.SubscribeEvent;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by Timber on 5/23/2017.
 | 
			
		||||
 */
 | 
			
		||||
public class Shutdown {
 | 
			
		||||
 | 
			
		||||
    @SubscribeEvent
 | 
			
		||||
    public void onShutdown(ShutdownEvent event) {
 | 
			
		||||
        System.out.println("Test");
 | 
			
		||||
        Rixa.getInstance().close();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -6,7 +6,6 @@ import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.EmbedBuilder;
 | 
			
		||||
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.LinkedList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,9 +9,10 @@ import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.RixaPermission;
 | 
			
		||||
import me.savvy.rixa.enums.Result;
 | 
			
		||||
import me.savvy.rixa.guild.management.GuildSettings;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.RixaModule;
 | 
			
		||||
import me.savvy.rixa.modules.levels.LevelsModule;
 | 
			
		||||
import me.savvy.rixa.modules.music.MusicModule;
 | 
			
		||||
import me.savvy.rixa.modules.twitter.TwitterModule;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Role;
 | 
			
		||||
@@ -19,7 +20,10 @@ import net.dv8tion.jda.core.entities.User;
 | 
			
		||||
 | 
			
		||||
import java.sql.ResultSet;
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by Timber on 5/23/2017.
 | 
			
		||||
@@ -33,26 +37,20 @@ public class RixaGuild {
 | 
			
		||||
    @Setter
 | 
			
		||||
    private GuildSettings guildSettings;
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private MusicModule musicModule;
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private TwitterModule twitterModule;
 | 
			
		||||
    @Getter
 | 
			
		||||
    private List<String> mutedMembers = new ArrayList<>();
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private LevelsModule levelsModule;
 | 
			
		||||
    private HashMap<String, RixaModule> modules;
 | 
			
		||||
 | 
			
		||||
    public RixaGuild(Guild guild) {
 | 
			
		||||
        this.guild = guild;
 | 
			
		||||
        this.modules = new HashMap<>();
 | 
			
		||||
        this.db = Rixa.getDatabase();
 | 
			
		||||
        setMusicModule(new MusicModule(guild));
 | 
			
		||||
        setLevelsModule(new LevelsModule(this));
 | 
			
		||||
        modules.put("Music", new MusicModule());
 | 
			
		||||
        modules.put("Levels", new LevelsModule());
 | 
			
		||||
        load();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void load() {
 | 
			
		||||
    public void load() {
 | 
			
		||||
        if (!(checkExists())) {
 | 
			
		||||
            Update update = new Update("INSERT INTO `core` (`guild_id`, `guild_name`, `description`, `keywords`) VALUES (?, ?, 'Description not set.', 'No Keywords Found.')");
 | 
			
		||||
            update.setString(guild.getId());
 | 
			
		||||
@@ -60,7 +58,7 @@ public class RixaGuild {
 | 
			
		||||
            db.send(update);
 | 
			
		||||
        }
 | 
			
		||||
        setGuildSettings(new GuildSettings(this.guild));
 | 
			
		||||
        addGuild(this);
 | 
			
		||||
        Guilds.addGuild(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GuildSettings getGuildSettings() {
 | 
			
		||||
@@ -177,28 +175,16 @@ public class RixaGuild {
 | 
			
		||||
            mutedMembers.add(user.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Getter
 | 
			
		||||
    private static Map<String, RixaGuild> guilds = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    private static void addGuild(RixaGuild guild) {
 | 
			
		||||
        if (check(guild.getGuild())) return;
 | 
			
		||||
        guilds.put(guild.getGuild().getId(), guild);
 | 
			
		||||
    public void save() {
 | 
			
		||||
        for (RixaModule module : modules.values()) {
 | 
			
		||||
            if (!module.isEnabled()) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            module.save();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static RixaGuild getGuild(Guild guild) {
 | 
			
		||||
        if (!check(guild)) {
 | 
			
		||||
            addGuild(new RixaGuild(guild));
 | 
			
		||||
    public RixaModule getModule(String levels) {
 | 
			
		||||
        return this.modules.get(levels);
 | 
			
		||||
    }
 | 
			
		||||
        return guilds.get(guild.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void removeGuild(RixaGuild guild) {
 | 
			
		||||
        if (!check(guild.getGuild())) return;
 | 
			
		||||
        guilds.remove(guild.getGuild().getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean check(Guild guild) {
 | 
			
		||||
        return guilds.containsKey(guild.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ public class GuildSettings {
 | 
			
		||||
    @Getter
 | 
			
		||||
    private boolean enlisted, joinVerification;
 | 
			
		||||
    @Getter
 | 
			
		||||
    private String prefix = "/", defaultRole, muteRole, joinMessage, quitMessage, joinPrivateMessage, description;
 | 
			
		||||
    private String prefix = "/", defaultRole, muteRole, joinMessage, quitMessage, joinPrivateMessage, description, currency;
 | 
			
		||||
    @Getter
 | 
			
		||||
    private TextChannel joinMessageChannel, quitMessageChannel;
 | 
			
		||||
    @Getter
 | 
			
		||||
@@ -48,9 +48,9 @@ public class GuildSettings {
 | 
			
		||||
    private void load() throws SQLException {
 | 
			
		||||
        if (!checkExists()) {
 | 
			
		||||
            Update update = new Update("INSERT INTO `settings` (`guild_id`, `log_enabled`, `log_channel`, `joinMessage`, `quitMessage`, `greetings`, `farewell`," +
 | 
			
		||||
                    " `prefix`, `joinPm`, `joinVerification`, `defaultRole`, `muteRole`)" +
 | 
			
		||||
                    " `prefix`, `joinPm`, `joinVerification`, `defaultRole`, `muteRole`, `currency`)" +
 | 
			
		||||
                    " VALUES ('" + guild.getId() + "', '0', 'default_value', 'default_value', 'default_value', 'default_value', 'default_value', '/'," +
 | 
			
		||||
                    " 'default', '0', 'default_value', 'default_value');");
 | 
			
		||||
                    " 'default', '0', 'default_value', 'default_value', ' tokens');");
 | 
			
		||||
            Rixa.getDatabase().send(update);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										35
									
								
								src/main/java/me/savvy/rixa/guild/management/Guilds.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/main/java/me/savvy/rixa/guild/management/Guilds.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
package me.savvy.rixa.guild.management;
 | 
			
		||||
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class Guilds {
 | 
			
		||||
 | 
			
		||||
    @Getter
 | 
			
		||||
    private static Map<String, RixaGuild> guilds = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    public static void addGuild(RixaGuild guild) {
 | 
			
		||||
        if (check(guild.getGuild())) return;
 | 
			
		||||
        guilds.put(guild.getGuild().getId(), guild);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static RixaGuild getGuild(Guild guild) {
 | 
			
		||||
        if (!check(guild)) {
 | 
			
		||||
            addGuild(new RixaGuild(guild));
 | 
			
		||||
        }
 | 
			
		||||
        return guilds.get(guild.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void removeGuild(RixaGuild guild) {
 | 
			
		||||
        if (!check(guild.getGuild())) return;
 | 
			
		||||
        guilds.remove(guild.getGuild().getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean check(Guild guild) {
 | 
			
		||||
        return guilds.containsKey(guild.getId());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,7 +5,8 @@ import me.majrly.database.statements.Query;
 | 
			
		||||
import me.majrly.database.statements.Update;
 | 
			
		||||
import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.enums.Result;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.levels.LevelsModule;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
import net.dv8tion.jda.core.entities.User;
 | 
			
		||||
 | 
			
		||||
@@ -39,7 +40,7 @@ public class UserData {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void register(UserData userData) {
 | 
			
		||||
        RixaGuild.getGuild(guild).getLevelsModule().registerUser(userData);
 | 
			
		||||
        ((LevelsModule) Guilds.getGuild(guild).getModule("Levels")).registerUser(userData);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void load() {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
package me.savvy.rixa.modules;
 | 
			
		||||
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by Timber on 5/23/2017.
 | 
			
		||||
 */
 | 
			
		||||
@@ -10,4 +12,8 @@ public interface RixaModule {
 | 
			
		||||
    String getDescription();
 | 
			
		||||
 | 
			
		||||
    boolean isEnabled();
 | 
			
		||||
 | 
			
		||||
    void load(RixaGuild guild);
 | 
			
		||||
 | 
			
		||||
    void save();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,49 @@
 | 
			
		||||
package me.savvy.rixa.modules.economy;
 | 
			
		||||
 | 
			
		||||
public class Economy {
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.modules.RixaModule;
 | 
			
		||||
import me.savvy.rixa.utils.DatabaseUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class Economy implements RixaModule {
 | 
			
		||||
 | 
			
		||||
    @Getter
 | 
			
		||||
    private RixaGuild rixaGuild;
 | 
			
		||||
    @Getter
 | 
			
		||||
    private Map<String, EconomyData> userData = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    private boolean enabled;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return "Economy";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getDescription() {
 | 
			
		||||
        return "Rixa Economy Module";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isEnabled() {
 | 
			
		||||
        return enabled;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void load(RixaGuild rixaGuild) {
 | 
			
		||||
        this.rixaGuild = rixaGuild;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void save() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEnabled(boolean enabled) {
 | 
			
		||||
        this.enabled = enabled;
 | 
			
		||||
        DatabaseUtils.update("modules", "levels", "guild_id", enabled, rixaGuild.getGuild().getId());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								src/main/java/me/savvy/rixa/modules/economy/EconomyData.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/main/java/me/savvy/rixa/modules/economy/EconomyData.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
package me.savvy.rixa.modules.economy;
 | 
			
		||||
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import lombok.Setter;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
import net.dv8tion.jda.core.entities.User;
 | 
			
		||||
 | 
			
		||||
public class EconomyData {
 | 
			
		||||
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private int amount;
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private Guild guild;
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private User user;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public EconomyData(User user, Guild guild) {
 | 
			
		||||
        setUser(user);
 | 
			
		||||
        setGuild(guild);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
package me.savvy.rixa.modules.levels;
 | 
			
		||||
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import lombok.Setter;
 | 
			
		||||
import me.majrly.database.Database;
 | 
			
		||||
import me.majrly.database.statements.Query;
 | 
			
		||||
import me.majrly.database.statements.Update;
 | 
			
		||||
import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.enums.Result;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.user.UserData;
 | 
			
		||||
import me.savvy.rixa.modules.RixaModule;
 | 
			
		||||
@@ -13,7 +13,6 @@ import me.savvy.rixa.utils.DatabaseUtils;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Member;
 | 
			
		||||
 | 
			
		||||
import java.sql.PreparedStatement;
 | 
			
		||||
import java.sql.ResultSet;
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
@@ -24,18 +23,13 @@ import java.util.*;
 | 
			
		||||
public class LevelsModule implements RixaModule {
 | 
			
		||||
 | 
			
		||||
    @Getter
 | 
			
		||||
    private final RixaGuild rixaGuild;
 | 
			
		||||
    private RixaGuild rixaGuild;
 | 
			
		||||
    @Getter
 | 
			
		||||
    private Map<String, UserData> userData = new HashMap<>();
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private boolean enabled;
 | 
			
		||||
 | 
			
		||||
    public LevelsModule(RixaGuild rixaGuild) {
 | 
			
		||||
        this.rixaGuild = rixaGuild;
 | 
			
		||||
        enabled = true;
 | 
			
		||||
        load();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private List<UserData> leaderboard(Member member) {
 | 
			
		||||
        Database db = Rixa.getDatabase();
 | 
			
		||||
        ResultSet rs = null;
 | 
			
		||||
@@ -50,7 +44,7 @@ public class LevelsModule implements RixaModule {
 | 
			
		||||
        try {
 | 
			
		||||
            while (rs != null && rs.next()) {
 | 
			
		||||
                if (member.getGuild().getMemberById(rs.getString("user_id")) == null) continue;
 | 
			
		||||
                UserData userData = rixaGuild.getLevelsModule().getUserData(rs.getString("user_id"));
 | 
			
		||||
                UserData userData = ((LevelsModule) rixaGuild.getModule("Levels")).getUserData(rs.getString("user_id"));
 | 
			
		||||
                userDataList.add(userData);
 | 
			
		||||
            }
 | 
			
		||||
            rs.getStatement().close();
 | 
			
		||||
@@ -104,6 +98,35 @@ public class LevelsModule implements RixaModule {
 | 
			
		||||
        return "Rixa levels module.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void load(RixaGuild rixaGuild) {
 | 
			
		||||
        try {
 | 
			
		||||
            this.rixaGuild = rixaGuild;
 | 
			
		||||
            Query query = new Query("SELECT * FROM `modules` WHERE `guild_id`=?;");
 | 
			
		||||
            query.setString(rixaGuild.getGuild().getId());
 | 
			
		||||
            Optional<?> o = Rixa.getDatabase().send(query);
 | 
			
		||||
            if (!o.isPresent()) return;
 | 
			
		||||
            else if (!(o.get() instanceof ResultSet)) return;
 | 
			
		||||
            ResultSet set = (ResultSet) o.get();
 | 
			
		||||
            if (set.next()) {
 | 
			
		||||
                setEnabled(set.getBoolean("levels"));
 | 
			
		||||
            } else {
 | 
			
		||||
                Update update = new Update("INSERT INTO `modules` (`guild_id`) VALUES (?);");
 | 
			
		||||
                update.setString(rixaGuild.getGuild().getId());
 | 
			
		||||
                Rixa.getDatabase().send(update);
 | 
			
		||||
                setEnabled(true);
 | 
			
		||||
            }
 | 
			
		||||
            set.close();
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void save() {
 | 
			
		||||
        DatabaseUtils.update("modules", "levels", "guild_id", enabled, rixaGuild.getGuild().getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void registerUser(UserData userData) {
 | 
			
		||||
        if (getUserData().containsKey(userData.getUser().getId())) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -124,62 +147,4 @@ public class LevelsModule implements RixaModule {
 | 
			
		||||
                (getRixaGuild().getGuild().getJDA().getUserById(key),
 | 
			
		||||
                        getRixaGuild().getGuild());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void load() {
 | 
			
		||||
        if (!(checkExists())) {
 | 
			
		||||
            this.enabled = true;
 | 
			
		||||
            insert();
 | 
			
		||||
        }
 | 
			
		||||
        String query = "SELECT `levels` FROM `modules` WHERE `guild_id` = ?;";
 | 
			
		||||
        PreparedStatement ps;
 | 
			
		||||
        ResultSet rs;
 | 
			
		||||
        try {
 | 
			
		||||
            ps = Rixa.getDatabase().getConnection().get().prepareStatement(query);
 | 
			
		||||
            ps.setString(1, getRixaGuild().getGuild().getId());
 | 
			
		||||
            rs = ps.executeQuery();
 | 
			
		||||
            if (rs.next()) {
 | 
			
		||||
                this.enabled = rs.getBoolean("levels");
 | 
			
		||||
            }
 | 
			
		||||
            ps.close();
 | 
			
		||||
            rs.close();
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean checkExists() {
 | 
			
		||||
        Result r = Result.FALSE;
 | 
			
		||||
        try {
 | 
			
		||||
            Query query = new Query("SELECT `guild_id` FROM `modules` WHERE `guild_id` = ?;");
 | 
			
		||||
            query.setString(rixaGuild.getGuild().getId());
 | 
			
		||||
            Optional<?> optional = Rixa.getDatabase().send(query);
 | 
			
		||||
            if (!optional.isPresent()) r = Result.ERROR;
 | 
			
		||||
            if (!(optional.get() instanceof ResultSet)) r = Result.ERROR;
 | 
			
		||||
            ResultSet set = (ResultSet) optional.get();
 | 
			
		||||
            if (r != Result.ERROR) {
 | 
			
		||||
                if (set.next()) {
 | 
			
		||||
                    r = Result.TRUE;
 | 
			
		||||
                } else {
 | 
			
		||||
                    r = Result.FALSE;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set.close();
 | 
			
		||||
            return r == Result.TRUE;
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void insert() {
 | 
			
		||||
        String query = "INSERT INTO `modules` (`guild_id`) VALUES (?);";
 | 
			
		||||
        Update update = new Update(query);
 | 
			
		||||
        update.setString(rixaGuild.getGuild().getId());
 | 
			
		||||
        Rixa.getDatabase().send(update);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEnabled(boolean enabled) {
 | 
			
		||||
        this.enabled = enabled;
 | 
			
		||||
        DatabaseUtils.update("modules", "levels", "guild_id", enabled, rixaGuild.getGuild().getId());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package me.savvy.rixa.modules.music;
 | 
			
		||||
 | 
			
		||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
 | 
			
		||||
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
 | 
			
		||||
import net.dv8tion.jda.core.audio.AudioSendHandler;
 | 
			
		||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by Timber on 3/13/2017.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,16 @@
 | 
			
		||||
package me.savvy.rixa.modules.music;
 | 
			
		||||
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import lombok.Setter;
 | 
			
		||||
import me.majrly.database.Database;
 | 
			
		||||
import me.majrly.database.statements.Query;
 | 
			
		||||
import me.majrly.database.statements.Update;
 | 
			
		||||
import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.enums.Result;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.modules.RixaModule;
 | 
			
		||||
import me.savvy.rixa.utils.DatabaseUtils;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
 | 
			
		||||
import java.sql.PreparedStatement;
 | 
			
		||||
import java.sql.ResultSet;
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
@@ -19,31 +19,28 @@ import java.util.Optional;
 | 
			
		||||
 * Created by Timber on 5/23/2017.
 | 
			
		||||
 */
 | 
			
		||||
public class MusicModule implements RixaModule {
 | 
			
		||||
 | 
			
		||||
    private Database db;
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private boolean enabled;
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private String musicRole;
 | 
			
		||||
    @Getter
 | 
			
		||||
    private Guild guild;
 | 
			
		||||
 | 
			
		||||
    public MusicModule(Guild guild) {
 | 
			
		||||
        this.guild = guild;
 | 
			
		||||
    @Override
 | 
			
		||||
    public void load(RixaGuild rixaGuild) {
 | 
			
		||||
        try {
 | 
			
		||||
            this.guild = rixaGuild.getGuild();
 | 
			
		||||
            this.enabled = false;
 | 
			
		||||
            this.musicRole = "default_value";
 | 
			
		||||
            db = Rixa.getDatabase();
 | 
			
		||||
        load();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void load() {
 | 
			
		||||
        Update music = new Update("CREATE TABLE IF NOT EXISTS `music` (`guild_id` varchar(255) NOT NULL, `music_role` varchar(255) NOT NULL, `enabled` INT(11) NOT NULL, PRIMARY KEY (`guild_id`));");
 | 
			
		||||
        db.send(music);
 | 
			
		||||
        if (!checkExists()) {
 | 
			
		||||
            Update update = new Update("INSERT INTO `music` (`guild_id`, `music_role`, `enabled`)" +
 | 
			
		||||
                    " VALUES ('" + guild.getId() + "', 'default_value', '0');");
 | 
			
		||||
            if (!DatabaseUtils.checkExists("music", guild)) {
 | 
			
		||||
                Update update = new Update("INSERT INTO `music` (`guild_id`, `music_role`, `enabled`) VALUES ('" + guild.getId() + "', 'default_value', '0');");
 | 
			
		||||
                db.send(update);
 | 
			
		||||
            }
 | 
			
		||||
        try {
 | 
			
		||||
            Query query = new Query("SELECT * FROM `modules` WHERE `guild_id` = ?");
 | 
			
		||||
            query.setString(guild.getId());
 | 
			
		||||
            Optional<?> optional = Rixa.getDatabase().send(query);
 | 
			
		||||
@@ -51,8 +48,8 @@ public class MusicModule implements RixaModule {
 | 
			
		||||
            if (!(optional.get() instanceof ResultSet)) return;
 | 
			
		||||
            ResultSet set = (ResultSet) optional.get();
 | 
			
		||||
            if (set.next()) {
 | 
			
		||||
                this.musicRole = set.getString("music_role");
 | 
			
		||||
                this.enabled = set.getBoolean("enabled");
 | 
			
		||||
                setMusicRole(set.getString("music_role"));
 | 
			
		||||
                setEnabled(set.getBoolean("enabled"));
 | 
			
		||||
            }
 | 
			
		||||
            set.close();
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
@@ -60,6 +57,12 @@ public class MusicModule implements RixaModule {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void save() {
 | 
			
		||||
        DatabaseUtils.update("music", "enabled", "guild_id", enabled, guild.getId());
 | 
			
		||||
        DatabaseUtils.update("music", "music_role", "guild_id", musicRole, guild.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return "Music";
 | 
			
		||||
@@ -70,43 +73,7 @@ public class MusicModule implements RixaModule {
 | 
			
		||||
        return "Listen to music in your voice channel.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public Result setEnabled(boolean val) {
 | 
			
		||||
        this.enabled = val;
 | 
			
		||||
        return DatabaseUtils.update("music", "enabled", "guild_id", val, guild.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isRoleRequired() {
 | 
			
		||||
        return (!musicRole.equalsIgnoreCase("default_value"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public Result setRole(String newRole) {
 | 
			
		||||
        this.musicRole = newRole;
 | 
			
		||||
        return DatabaseUtils.update("music", "music_role", "guild_id", newRole, guild.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean checkExists() {
 | 
			
		||||
        Result r = Result.FALSE;
 | 
			
		||||
        try {
 | 
			
		||||
            Query query = new Query("SELECT `guild_id` FROM `music` WHERE `guild_id` = '" +
 | 
			
		||||
                    guild.getId() + "';");
 | 
			
		||||
            Optional<?> optional = Rixa.getDatabase().send(query);
 | 
			
		||||
            if (!optional.isPresent()) r = Result.ERROR;
 | 
			
		||||
            if (!(optional.get() instanceof ResultSet)) r = Result.ERROR;
 | 
			
		||||
            ResultSet set = (ResultSet) optional.get();
 | 
			
		||||
            if (r != Result.ERROR) {
 | 
			
		||||
                if (set.next()) {
 | 
			
		||||
                    r = Result.TRUE;
 | 
			
		||||
                } else {
 | 
			
		||||
                    r = Result.FALSE;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set.close();
 | 
			
		||||
            return r == Result.TRUE;
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return (musicRole != null && !musicRole.equalsIgnoreCase("default_value"));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package me.savvy.rixa.modules.reactions.react;
 | 
			
		||||
 | 
			
		||||
import me.savvy.rixa.commands.admin.ConfigCommand;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.React;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.ReactHandle;
 | 
			
		||||
import me.savvy.rixa.utils.MessageBuilder;
 | 
			
		||||
@@ -30,7 +31,7 @@ public class ConfigReaction implements React {
 | 
			
		||||
        if(guild == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(guild);
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(guild);
 | 
			
		||||
        String prefix = rixaGuild.getGuildSettings().getPrefix();
 | 
			
		||||
        MessageBuilder builder = null;
 | 
			
		||||
        int page = 500;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ package me.savvy.rixa.modules.reactions.react;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandHandler;
 | 
			
		||||
import me.savvy.rixa.commands.handlers.CommandType;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.React;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.ReactHandle;
 | 
			
		||||
import net.dv8tion.jda.core.EmbedBuilder;
 | 
			
		||||
@@ -26,7 +26,7 @@ public class HelpReaction implements React {
 | 
			
		||||
        }
 | 
			
		||||
        Message message = event.getChannel().getMessageById(event.getMessageId()).complete();
 | 
			
		||||
        String title = message.getEmbeds().get(0).getTitle().split(": ")[1];
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(event.getJDA().getGuildById(title));
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(event.getJDA().getGuildById(title));
 | 
			
		||||
        String prefix = rixaGuild.getGuildSettings().getPrefix();
 | 
			
		||||
        EmbedBuilder embedBuilder;
 | 
			
		||||
        try {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,12 @@
 | 
			
		||||
package me.savvy.rixa.modules.reactions.react;
 | 
			
		||||
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.guild.management.Guilds;
 | 
			
		||||
import me.savvy.rixa.modules.levels.LevelsModule;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.React;
 | 
			
		||||
import me.savvy.rixa.modules.reactions.handlers.ReactHandle;
 | 
			
		||||
import net.dv8tion.jda.core.MessageBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.ChannelType;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Message;
 | 
			
		||||
import net.dv8tion.jda.core.entities.MessageEmbed;
 | 
			
		||||
import net.dv8tion.jda.core.events.message.guild.react.GuildMessageReactionAddEvent;
 | 
			
		||||
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent;
 | 
			
		||||
 | 
			
		||||
@@ -27,7 +26,7 @@ public class LeaderboardReaction implements React {
 | 
			
		||||
        if(guild == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        RixaGuild rixaGuild = RixaGuild.getGuild(guild);
 | 
			
		||||
        RixaGuild rixaGuild = Guilds.getGuild(guild);
 | 
			
		||||
        int page = 500;
 | 
			
		||||
        switch (event.getReaction().getEmote().getName()) {
 | 
			
		||||
            case "\u2B05":// previous
 | 
			
		||||
@@ -38,7 +37,7 @@ public class LeaderboardReaction implements React {
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        if(page != 500) {
 | 
			
		||||
            me.savvy.rixa.utils.MessageBuilder builder = rixaGuild.getLevelsModule().leaderboard
 | 
			
		||||
            me.savvy.rixa.utils.MessageBuilder builder = ((LevelsModule)  rixaGuild.getModule("Levels")).leaderboard
 | 
			
		||||
                    (event.getMember(), page);
 | 
			
		||||
            if (builder == null) return;
 | 
			
		||||
            message.editMessage(builder.getBuilder().build()).queue();
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,10 @@ import lombok.Getter;
 | 
			
		||||
import lombok.Setter;
 | 
			
		||||
import me.savvy.rixa.guild.RixaGuild;
 | 
			
		||||
import me.savvy.rixa.modules.RixaModule;
 | 
			
		||||
import twitter4j.*;
 | 
			
		||||
import twitter4j.Twitter;
 | 
			
		||||
import twitter4j.TwitterFactory;
 | 
			
		||||
import twitter4j.TwitterStream;
 | 
			
		||||
import twitter4j.TwitterStreamFactory;
 | 
			
		||||
import twitter4j.conf.ConfigurationBuilder;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -57,4 +60,10 @@ public class TwitterModule implements RixaModule {
 | 
			
		||||
    public String getDescription() {
 | 
			
		||||
        return "Twitter feed, tweet & more.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void load(RixaGuild guild) { }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void save() { }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,14 @@
 | 
			
		||||
package me.savvy.rixa.utils;
 | 
			
		||||
 | 
			
		||||
import me.majrly.database.statements.Query;
 | 
			
		||||
import me.majrly.database.statements.Update;
 | 
			
		||||
import me.savvy.rixa.Rixa;
 | 
			
		||||
import me.savvy.rixa.enums.Result;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Guild;
 | 
			
		||||
 | 
			
		||||
import java.sql.ResultSet;
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
 | 
			
		||||
public class DatabaseUtils {
 | 
			
		||||
 | 
			
		||||
@@ -13,4 +19,27 @@ public class DatabaseUtils {
 | 
			
		||||
        Rixa.getDatabase().send(update);
 | 
			
		||||
        return Result.TRUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean checkExists(String table, Guild guild) {
 | 
			
		||||
        Result r = Result.FALSE;
 | 
			
		||||
        try {
 | 
			
		||||
            Query query = new Query("SELECT `guild_id` FROM `" + table + "` WHERE `guild_id` = '" + guild.getId() + "';");
 | 
			
		||||
            Optional<?> optional = Rixa.getDatabase().send(query);
 | 
			
		||||
            if (!optional.isPresent()) r = Result.ERROR;
 | 
			
		||||
            if (!(optional.get() instanceof ResultSet)) r = Result.ERROR;
 | 
			
		||||
            ResultSet set = (ResultSet) optional.get();
 | 
			
		||||
            if (r != Result.ERROR) {
 | 
			
		||||
                if (set.next()) {
 | 
			
		||||
                    r = Result.TRUE;
 | 
			
		||||
                } else {
 | 
			
		||||
                    r = Result.FALSE;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set.close();
 | 
			
		||||
            return r == Result.TRUE;
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            System.out.println("INFO: Failed to check if exists : " + e.getLocalizedMessage());
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,7 +2,10 @@ package me.savvy.rixa.utils;
 | 
			
		||||
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import net.dv8tion.jda.core.EmbedBuilder;
 | 
			
		||||
import net.dv8tion.jda.core.entities.*;
 | 
			
		||||
import net.dv8tion.jda.core.entities.Message;
 | 
			
		||||
import net.dv8tion.jda.core.entities.MessageEmbed;
 | 
			
		||||
import net.dv8tion.jda.core.entities.TextChannel;
 | 
			
		||||
import net.dv8tion.jda.core.entities.User;
 | 
			
		||||
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user