Moved Commands, added sub command categories, added ShutdownCommand
This commit is contained in:
parent
cd3407e748
commit
67cc8c2b7a
@ -2,12 +2,12 @@ package io.rixa.bot;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||||
import io.rixa.bot.commands.cmds.InfoCommand;
|
import io.rixa.bot.commands.cmds.general.InfoCommand;
|
||||||
import io.rixa.bot.commands.cmds.PingCommand;
|
import io.rixa.bot.commands.cmds.general.PingCommand;
|
||||||
import io.rixa.bot.commands.cmds.ServerInfoCommand;
|
import io.rixa.bot.commands.cmds.general.ServerInfoCommand;
|
||||||
import io.rixa.bot.commands.handler.CommandHandler;
|
import io.rixa.bot.commands.handler.CommandHandler;
|
||||||
import io.rixa.bot.commands.perms.RixaPermission;
|
import io.rixa.bot.commands.perms.RixaPermission;
|
||||||
import io.rixa.bot.commands.cmds.HelpCommand;
|
import io.rixa.bot.commands.cmds.general.HelpCommand;
|
||||||
import io.rixa.bot.data.config.Configuration;
|
import io.rixa.bot.data.config.Configuration;
|
||||||
import io.rixa.bot.data.storage.DatabaseAdapter;
|
import io.rixa.bot.data.storage.DatabaseAdapter;
|
||||||
import io.rixa.bot.events.BotJoinListener;
|
import io.rixa.bot.events.BotJoinListener;
|
||||||
@ -124,4 +124,8 @@ public class Rixa {
|
|||||||
public static Rixa getInstance() {
|
public static Rixa getInstance() {
|
||||||
return (instance == null) ? new Rixa() : instance;
|
return (instance == null) ? new Rixa() : instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
shardList.forEach(JDA::shutdown);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package io.rixa.bot.commands.cmds;
|
package io.rixa.bot.commands.cmds.general;
|
||||||
|
|
||||||
import io.rixa.bot.commands.Command;
|
import io.rixa.bot.commands.Command;
|
||||||
import io.rixa.bot.commands.perms.RixaPermission;
|
import io.rixa.bot.commands.perms.RixaPermission;
|
@ -1,4 +1,4 @@
|
|||||||
package io.rixa.bot.commands.cmds;
|
package io.rixa.bot.commands.cmds.general;
|
||||||
|
|
||||||
import io.rixa.bot.Rixa;
|
import io.rixa.bot.Rixa;
|
||||||
import io.rixa.bot.commands.Command;
|
import io.rixa.bot.commands.Command;
|
@ -1,4 +1,4 @@
|
|||||||
package io.rixa.bot.commands.cmds;
|
package io.rixa.bot.commands.cmds.general;
|
||||||
|
|
||||||
import io.rixa.bot.commands.Command;
|
import io.rixa.bot.commands.Command;
|
||||||
import io.rixa.bot.commands.perms.RixaPermission;
|
import io.rixa.bot.commands.perms.RixaPermission;
|
@ -1,4 +1,4 @@
|
|||||||
package io.rixa.bot.commands.cmds;
|
package io.rixa.bot.commands.cmds.general;
|
||||||
|
|
||||||
import io.rixa.bot.commands.Command;
|
import io.rixa.bot.commands.Command;
|
||||||
import io.rixa.bot.commands.perms.RixaPermission;
|
import io.rixa.bot.commands.perms.RixaPermission;
|
@ -0,0 +1,38 @@
|
|||||||
|
package io.rixa.bot.commands.cmds.other;
|
||||||
|
|
||||||
|
import io.rixa.bot.Rixa;
|
||||||
|
import io.rixa.bot.commands.Command;
|
||||||
|
import io.rixa.bot.commands.perms.RixaPermission;
|
||||||
|
import io.rixa.bot.guild.RixaGuild;
|
||||||
|
import io.rixa.bot.guild.manager.GuildManager;
|
||||||
|
import io.rixa.bot.utils.MessageFactory;
|
||||||
|
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
|
public class ShutdownCommand extends Command {
|
||||||
|
|
||||||
|
public ShutdownCommand(String command, RixaPermission rixaPermission, String description) {
|
||||||
|
super(command, rixaPermission, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(GuildMessageReceivedEvent event) {
|
||||||
|
if (!(Rixa.getInstance().getConfiguration().isBotAdmin(event.getAuthor().getId()))) {
|
||||||
|
new MessageFactory(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
MessageFactory.create("Shutting down...").queue(event.getChannel());
|
||||||
|
for (RixaGuild rixaGuild : GuildManager.getInstance().getGuilds().values()) {
|
||||||
|
Thread.sleep(50);
|
||||||
|
rixaGuild.save();
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
Rixa.getInstance().close();
|
||||||
|
System.exit(0);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Rixa.getInstance().close();
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package io.rixa.bot.guild.manager;
|
package io.rixa.bot.guild.manager;
|
||||||
|
|
||||||
|
import gnu.trove.map.TByteByteMap;
|
||||||
import io.rixa.bot.data.storage.DatabaseAdapter;
|
import io.rixa.bot.data.storage.DatabaseAdapter;
|
||||||
import io.rixa.bot.data.storage.enums.Statements;
|
import io.rixa.bot.data.storage.enums.Statements;
|
||||||
import io.rixa.bot.guild.RixaGuild;
|
import io.rixa.bot.guild.RixaGuild;
|
||||||
@ -52,4 +53,8 @@ public class GuildManager {
|
|||||||
(Statements.INSERT_CORE.getStatement(),
|
(Statements.INSERT_CORE.getStatement(),
|
||||||
guild.getId(), guild.getName(), "Description not set.", "No Keywords Found ");
|
guild.getId(), guild.getName(), "Description not set.", "No Keywords Found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, RixaGuild> getGuilds() {
|
||||||
|
return rixaGuildMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user