mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-02-11 05:58:26 -06:00
Weirdest thing ever
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -29,9 +29,9 @@
|
||||
<dependencies>
|
||||
<!--Discord4J API-->
|
||||
<dependency>
|
||||
<groupId>com.github.austinv11</groupId>
|
||||
<groupId>com.github.discord4j</groupId>
|
||||
<artifactId>Discord4J</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<!-- Allows you to log events from Discord4J -->
|
||||
<dependency>
|
||||
|
||||
@@ -44,7 +44,13 @@ public class Main {
|
||||
//Log in to discord
|
||||
client = createClient(BotSettings.TOKEN.get());
|
||||
if (client == null)
|
||||
throw new NullPointerException("Failed to log in! Client cannot be null!");
|
||||
throw new NullPointerException("Failed to build! Client cannot be null!");
|
||||
|
||||
//Register events
|
||||
EventDispatcher dispatcher = client.getDispatcher();
|
||||
dispatcher.registerListener(new ReadyEventListener());
|
||||
|
||||
client.login();
|
||||
|
||||
UpdateDisPwData.init();
|
||||
|
||||
@@ -62,10 +68,6 @@ public class Main {
|
||||
Logger.getLogger().exception(null, "'Spark ERROR' by 'PANIC! AT THE WEBSITE'", e, Main.class, true);
|
||||
}
|
||||
|
||||
//Register events
|
||||
EventDispatcher dispatcher = client.getDispatcher();
|
||||
dispatcher.registerListener(new ReadyEventListener());
|
||||
|
||||
//Register modules
|
||||
CommandExecutor executor = CommandExecutor.getExecutor().enable();
|
||||
executor.registerCommand(new HelpCommand());
|
||||
@@ -97,7 +99,7 @@ public class Main {
|
||||
ClientBuilder clientBuilder = new ClientBuilder(); // Creates the ClientBuilder instance
|
||||
clientBuilder.withToken(token).withRecommendedShardCount(); // Adds the login info to the builder
|
||||
try {
|
||||
return clientBuilder.login();
|
||||
return clientBuilder.build();
|
||||
} catch (DiscordException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ public class DatabaseManager {
|
||||
System.out.println("Connected to MySQL database!");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to connect to MySQL database! Is it properly configured?");
|
||||
Logger.getLogger().exception(null, "Connecting to MySQL server failed.", e, this.getClass(), true);
|
||||
e.printStackTrace();
|
||||
Logger.getLogger().exception(null, "Connecting to MySQL server failed.", e, this.getClass(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.cloudcraftgaming.discal.api.message.MessageManager;
|
||||
import com.cloudcraftgaming.discal.bot.internal.network.discordbots.UpdateDisBotData;
|
||||
import com.cloudcraftgaming.discal.bot.internal.network.discordpw.UpdateDisPwData;
|
||||
import com.cloudcraftgaming.discal.bot.internal.service.TimeManager;
|
||||
import com.cloudcraftgaming.discal.logger.Logger;
|
||||
import sx.blah.discord.api.events.EventSubscriber;
|
||||
import sx.blah.discord.handle.impl.events.ReadyEvent;
|
||||
|
||||
@@ -16,11 +17,16 @@ import sx.blah.discord.handle.impl.events.ReadyEvent;
|
||||
public class ReadyEventListener {
|
||||
@EventSubscriber
|
||||
public void onReadyEvent(ReadyEvent event) {
|
||||
TimeManager.getManager().init();
|
||||
Logger.getLogger().debug("Ready!");
|
||||
try {
|
||||
TimeManager.getManager().init();
|
||||
|
||||
UpdateDisBotData.init();
|
||||
UpdateDisPwData.init();
|
||||
UpdateDisBotData.init();
|
||||
UpdateDisPwData.init();
|
||||
|
||||
MessageManager.reloadLangs();
|
||||
MessageManager.reloadLangs();
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger().exception(null, "BAD!!!", e, this.getClass(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import com.cloudcraftgaming.discal.Main;
|
||||
import com.cloudcraftgaming.discal.api.database.DatabaseManager;
|
||||
import com.cloudcraftgaming.discal.api.object.BotSettings;
|
||||
import com.cloudcraftgaming.discal.web.handler.DiscordAccountHandler;
|
||||
import sx.blah.discord.handle.obj.ActivityType;
|
||||
import sx.blah.discord.handle.obj.StatusType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.TimerTask;
|
||||
@@ -47,7 +49,7 @@ public class StatusChanger extends TimerTask {
|
||||
status = status.replace("%annCount%", DatabaseManager.getManager().getAnnouncementCount() + "");
|
||||
status = status.replace("%shards%", Main.client.getShardCount() + "");
|
||||
status = status.replace("%users%", DiscordAccountHandler.getHandler().accountCount() + "");
|
||||
Main.client.changePlayingText(status);
|
||||
Main.client.changePresence(StatusType.ONLINE, ActivityType.PLAYING, status);
|
||||
|
||||
//Set new index.
|
||||
if (index + 1 >= statuses.size()) {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Logger {
|
||||
//Can ignore silently...
|
||||
}
|
||||
|
||||
if (Main.getSelfUser() != null) {
|
||||
if (Main.getSelfUser() != null && Main.client.isLoggedIn()) {
|
||||
IUser bot = Main.getSelfUser();
|
||||
|
||||
if (post) {
|
||||
|
||||
Reference in New Issue
Block a user