Skip to content

Commit 9ed52b4

Browse files
committed
Ensure status is checked before sending messages
1 parent 14adf47 commit 9ed52b4

File tree

1 file changed

+8
-0
lines changed
  • src/main/java/net/clementraynaud/skoice/bot

1 file changed

+8
-0
lines changed

src/main/java/net/clementraynaud/skoice/bot/Bot.java

+8
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class Bot {
7070
private final MenuFactory menuFactory;
7171
private JDA jda;
7272
private BotStatus status = BotStatus.NOT_CONNECTED;
73+
private boolean isStatusChecked = false;
7374
private String tokenManagerId;
7475
private String guildId;
7576
private String inviteUrl;
@@ -89,6 +90,7 @@ public void connect() {
8990

9091
public void connect(CommandSender sender) {
9192
if (!this.plugin.getConfigYamlFile().contains(ConfigField.TOKEN.toString())) {
93+
this.isStatusChecked = true;
9294
this.plugin.getLogger().warning(this.plugin.getLang().getMessage("logger.warning.no-token"));
9395
return;
9496
}
@@ -121,6 +123,7 @@ public void connect(CommandSender sender) {
121123
.addEventListeners(new ReadyListener(this.plugin))
122124
.build();
123125
} catch (InvalidTokenException | IllegalArgumentException | ErrorResponseException e) {
126+
this.isStatusChecked = true;
124127
this.plugin.getLogger().warning(this.plugin.getLang().getMessage("logger.error.bot-could-not-connect"));
125128
this.plugin.getConfigYamlFile().remove(ConfigField.TOKEN.toString());
126129
if (tokenManager != null) {
@@ -262,6 +265,7 @@ public void updateStatus() {
262265
}
263266
}
264267

268+
this.isStatusChecked = true;
265269
this.updateActivity();
266270
}
267271
}
@@ -276,6 +280,10 @@ public void updateActivity() {
276280
}
277281

278282
public void sendIncompleteConfigurationAlert(Player player, boolean sendIfPermissionMissing, boolean force) {
283+
if (!this.isStatusChecked) {
284+
return;
285+
}
286+
279287
if (player.hasPermission(Argument.MANAGE_PERMISSION) || force) {
280288
if (this.status == BotStatus.NOT_CONNECTED) {
281289
if (this.plugin.getConfigYamlFile().getBoolean(ConfigField.TOOLTIPS.toString())) {

0 commit comments

Comments
 (0)