Skip to content

Commit 4355dc3

Browse files
committed
Fix DUNCTEBOT-TY
1 parent 5aff6a0 commit 4355dc3

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ plugins {
3535
id("org.jmailen.kotlinter") version "3.5.1"
3636
}
3737

38-
val numberVersion = "3.106.5"
38+
val numberVersion = "3.106.6"
3939

4040
project.group = "ml.duncte123.skybot"
4141
project.version = "${numberVersion}_${getGitHash()}"

src/main/java/ml/duncte123/skybot/SkyBot.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,16 @@
5454

5555
public final class SkyBot {
5656
private static SkyBot instance;
57-
private final ShardManager shardManager;
58-
private WebSocketClient client;
59-
6057
private static final MemberCachePolicy PATRON_POLICY = (member) -> {
6158
// Member needs to be cached for JDA to fire role update event
6259
// the guild check is required for JDA to catch role updates in the support guild
6360
return member.getGuild().getIdLong() == Settings.SUPPORT_GUILD_ID &&
6461
member.getRoles().stream().anyMatch((role) -> role.getIdLong() == Settings.PATRONS_ROLE);
6562
};
63+
private final ShardManager shardManager;
64+
private WebSocketClient client;
6665

67-
// Sigh, might need to convert this to spring
68-
@SuppressWarnings("PMD.AssignmentToNonFinalStatic")
6966
private SkyBot() throws LoginException {
70-
instance = this;
71-
7267
// Load in our container
7368
final Variables variables = new Variables();
7469

@@ -102,13 +97,13 @@ private SkyBot() throws LoginException {
10297
final EventManager eventManager = new EventManager(variables);
10398
// Build our shard manager
10499
final DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.create(
105-
GatewayIntent.GUILD_MEMBERS,
106-
GatewayIntent.GUILD_INVITES,
107-
GatewayIntent.GUILD_BANS,
108-
GatewayIntent.GUILD_EMOJIS,
109-
GatewayIntent.GUILD_VOICE_STATES,
110-
GatewayIntent.GUILD_MESSAGES
111-
)
100+
GatewayIntent.GUILD_MEMBERS,
101+
GatewayIntent.GUILD_INVITES,
102+
GatewayIntent.GUILD_BANS,
103+
GatewayIntent.GUILD_EMOJIS,
104+
GatewayIntent.GUILD_VOICE_STATES,
105+
GatewayIntent.GUILD_MESSAGES
106+
)
112107
.setToken(token)
113108
.setShardsTotal(totalShards)
114109
.setActivityProvider((shardId) -> Activity.playing(
@@ -138,7 +133,7 @@ private SkyBot() throws LoginException {
138133
this.shardManager = builder.build();
139134

140135
HelpEmbeds.init(commandManager);
141-
136+
142137
if (config.websocket.enable) {
143138
client = new WebSocketClient(variables, shardManager);
144139
}
@@ -185,7 +180,7 @@ public WebSocketClient getWebsocketClient() {
185180
}
186181

187182
public static void main(final String[] args) throws LoginException {
188-
new SkyBot();
183+
instance = new SkyBot();
189184
}
190185

191186
public static SkyBot getInstance() {

src/main/kotlin/ml/duncte123/skybot/web/WebSocketClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class WebSocketClient(
213213
}
214214

215215
private fun connect() {
216-
if (socket != null && socket.isOpen) {
216+
if (this::socket.isInitialized && socket.isOpen) {
217217
socket.sendClose(WebSocketCloseCode.NORMAL)
218218
}
219219

0 commit comments

Comments
 (0)