@@ -126,17 +126,7 @@ public void connect(CommandSender sender) {
126
126
}
127
127
128
128
public boolean isAdministrator () {
129
- Guild guild = this .plugin .getBot ().getGuild ();
130
- if (guild == null ) {
131
- return false ;
132
- }
133
-
134
- if (this .getGuild ().getRequiredMFALevel () == Guild .MFALevel .TWO_FACTOR_AUTH
135
- && !this .jda .getSelfUser ().isMfaEnabled ()) {
136
- return false ;
137
- }
138
-
139
- return guild .getSelfMember ().hasPermission (Permission .ADMINISTRATOR );
129
+ return this .status .ordinal () > BotStatus .MISSING_PERMISSION .ordinal ();
140
130
}
141
131
142
132
public void setDefaultAvatar () {
@@ -211,6 +201,7 @@ public void updateStatus() {
211
201
if (!this .plugin .getConfigYamlFile ().contains (ConfigField .TOKEN .toString ())) {
212
202
this .plugin .getLogger ().warning (this .plugin .getLang ().getMessage ("logger.warning.no-token" ));
213
203
}
204
+
214
205
} else {
215
206
if (this .guildId == null ) {
216
207
List <Guild > guilds = this .jda .getGuilds ();
@@ -224,30 +215,36 @@ public void updateStatus() {
224
215
this .status = BotStatus .MULTIPLE_GUILDS ;
225
216
this .plugin .getLogger ().warning (this .plugin .getLang ().getMessage ("logger.warning.multiple-guilds" ));
226
217
}
218
+
227
219
} else if (this .getGuild ().getRequiredMFALevel () == Guild .MFALevel .TWO_FACTOR_AUTH
228
220
&& !this .jda .getSelfUser ().isMfaEnabled ()) {
229
221
this .status = BotStatus .MFA_REQUIRED ;
230
222
this .plugin .getLogger ().warning (this .plugin .getLang ().getMessage ("logger.warning.two-factor-authentication" ));
231
- } else if (!this .isAdministrator ()) {
223
+
224
+ } else if (!this .getGuild ().getSelfMember ().hasPermission (Permission .ADMINISTRATOR )) {
232
225
this .status = BotStatus .MISSING_PERMISSION ;
233
226
this .jda .retrieveApplicationInfo ().queue (applicationInfo -> {
234
227
applicationInfo .setRequiredScopes ("applications.commands" );
235
228
this .plugin .getLogger ().severe (this .plugin .getLang ().getMessage ("logger.error.missing-permission" , applicationInfo .getInviteUrl (Permission .ADMINISTRATOR )));
236
229
});
230
+
237
231
} else if (!this .plugin .getConfigYamlFile ().contains (ConfigField .VOICE_CHANNEL_ID .toString ())) {
238
232
this .status = BotStatus .NO_VOICE_CHANNEL ;
239
233
this .plugin .getLogger ().warning (this .plugin .getLang ().getMessage ("logger.warning.no-voice-channel" ));
234
+
240
235
} else if (!this .plugin .getConfigYamlFile ().contains (ConfigField .HORIZONTAL_RADIUS .toString ())
241
236
|| !this .plugin .getConfigYamlFile ().contains (ConfigField .VERTICAL_RADIUS .toString ())) {
242
237
this .status = BotStatus .NO_RADIUS ;
243
238
this .plugin .getLogger ().warning (this .plugin .getLang ().getMessage ("logger.warning.no-radius" ));
239
+
244
240
} else {
245
241
this .status = BotStatus .READY ;
246
242
this .plugin .getServer ().getScheduler ().runTask (this .plugin , () -> {
247
243
SystemReadyEvent event = new SystemReadyEvent ();
248
244
this .plugin .getServer ().getPluginManager ().callEvent (event );
249
245
});
250
246
}
247
+
251
248
this .updateActivity ();
252
249
}
253
250
}
0 commit comments