2017-05-23 17:19:15 +00:00
|
|
|
package me.savvy.rixa;
|
|
|
|
|
2017-05-24 13:16:39 +00:00
|
|
|
import me.savvy.rixa.commands.admin.BatchMoveCommand;
|
2017-05-23 17:19:15 +00:00
|
|
|
import me.savvy.rixa.commands.general.HelpCommand;
|
|
|
|
import me.savvy.rixa.commands.general.InfoCommand;
|
2017-05-24 13:16:39 +00:00
|
|
|
import me.savvy.rixa.commands.general.PingCommand;
|
2017-05-23 17:19:15 +00:00
|
|
|
import me.savvy.rixa.commands.general.ServerInfoCommand;
|
2017-05-24 13:16:39 +00:00
|
|
|
import me.savvy.rixa.commands.handlers.CommandExec;
|
2017-05-23 17:19:15 +00:00
|
|
|
import me.savvy.rixa.commands.handlers.CommandHandler;
|
2017-05-24 13:16:39 +00:00
|
|
|
import me.savvy.rixa.commands.mod.DeleteMessagesCommand;
|
|
|
|
import me.savvy.rixa.commands.mod.PurgeCommand;
|
|
|
|
import me.savvy.rixa.events.BotEvent;
|
2017-05-23 17:19:15 +00:00
|
|
|
import me.savvy.rixa.events.MessageEvent;
|
|
|
|
import me.savvy.rixa.modules.reactions.handlers.ReactionManager;
|
|
|
|
import me.savvy.rixa.modules.reactions.react.HelpReaction;
|
|
|
|
import net.dv8tion.jda.core.AccountType;
|
|
|
|
import net.dv8tion.jda.core.JDA;
|
|
|
|
import net.dv8tion.jda.core.JDABuilder;
|
|
|
|
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 javax.security.auth.login.LoginException;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Timber on 5/7/2017.
|
|
|
|
*/
|
|
|
|
public class Rixa {
|
|
|
|
|
|
|
|
private static List<JDA> shardsList;
|
|
|
|
private static long timeUp;
|
|
|
|
private static Rixa instance; // String search = event.getMessage().getContent().substring(event.getMessage().getContent().indexOf(" ") + 1);
|
|
|
|
|
|
|
|
public static void main(String[] args) throws LoginException, InterruptedException, RateLimitedException {
|
|
|
|
instance = new Rixa();
|
|
|
|
shardsList = new LinkedList<>();
|
2017-05-24 13:16:39 +00:00
|
|
|
int shards = 3;
|
|
|
|
for(int i = 0; i < shards; i++) {
|
2017-05-23 17:19:15 +00:00
|
|
|
Logger.getLogger("Rixa").info("Loading shard #" + i);
|
|
|
|
JDABuilder jda = new JDABuilder(AccountType.BOT)
|
2017-05-24 13:16:39 +00:00
|
|
|
.setToken("MjkxNTM5Njg2NTEyNTI1MzMy.DAZKfQ.kIHSmuCJHhklyC3gBAi0c_VKp-w")
|
2017-05-23 17:19:15 +00:00
|
|
|
.setEventManager(new AnnotatedEventManager())
|
|
|
|
.addEventListener(new MessageEvent())
|
2017-05-24 13:16:39 +00:00
|
|
|
.addEventListener(new BotEvent())
|
2017-05-23 17:19:15 +00:00
|
|
|
.setGame(Game.of("Rixa 1.0 | In Dev", "http://rixa.io"))
|
|
|
|
.setAutoReconnect(true)
|
|
|
|
.setStatus(OnlineStatus.ONLINE)
|
|
|
|
.setAudioEnabled(true)
|
|
|
|
.useSharding(i, shards);
|
|
|
|
shardsList.add(jda.buildBlocking());
|
2017-05-24 13:16:39 +00:00
|
|
|
getInstance().getLogger().info("Shard #" + i + " has been loaded");
|
2017-05-23 17:19:15 +00:00
|
|
|
}
|
|
|
|
timeUp = System.currentTimeMillis();
|
2017-05-24 13:16:39 +00:00
|
|
|
register(new CommandExec[] {
|
|
|
|
new InfoCommand(), new ServerInfoCommand(), new HelpCommand(),
|
|
|
|
new DeleteMessagesCommand(), new PingCommand(), new PurgeCommand(),
|
|
|
|
new BatchMoveCommand() });
|
2017-05-23 17:19:15 +00:00
|
|
|
ReactionManager.registerReaction(new HelpReaction());
|
|
|
|
}
|
|
|
|
|
2017-05-24 13:16:39 +00:00
|
|
|
private static void register(CommandExec commandExecs[]) {
|
|
|
|
for (CommandExec command: commandExecs) {
|
|
|
|
CommandHandler.registerCommand(command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-23 17:19:15 +00:00
|
|
|
public static Rixa getInstance() {
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getTimeUp() {
|
|
|
|
return timeUp;
|
|
|
|
}
|
2017-05-24 13:16:39 +00:00
|
|
|
|
|
|
|
public Logger getLogger() {
|
|
|
|
return Logger.getLogger("Rixa");
|
|
|
|
}
|
2017-05-23 17:19:15 +00:00
|
|
|
}
|