File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
src/main/java/com/hackclub/hccore Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -92,15 +92,20 @@ public void onAsyncPlayerChat(final AsyncPlayerChatEvent event) {
9292 }
9393
9494 public static boolean isSlackJoinAllowed (PlayerData data ) {
95- if (!HCCorePlugin .getPlugin (HCCorePlugin .class ).getConfig ()
95+ HCCorePlugin plugin = HCCorePlugin .getPlugin (HCCorePlugin .class );
96+
97+ if (!plugin .getConfig ()
9698 .getBoolean ("settings.slack-link.enabled" , false )) {
9799 return true ;
98100 }
99- if (!HCCorePlugin . getPlugin ( HCCorePlugin . class ) .getConfig ()
101+ if (!plugin .getConfig ()
100102 .getBoolean ("settings.slack-link.required" , false )) {
101103 return true ;
102104 }
103- return data .getSlackId () != null ;
105+
106+ String id = data .getSlackId ();
107+
108+ return !plugin .getSlackBot ().isDeactivated (id );
104109 }
105110
106111
Original file line number Diff line number Diff line change @@ -460,6 +460,21 @@ public void onCustomAdvancementProgressed(ProgressionUpdateEvent e) {
460460 }
461461 }
462462
463+ public boolean isDeactivated (String id ) {
464+ MethodsClient client = app .getClient ();
465+
466+ try {
467+ var res = client .usersInfo (r -> r .token (getBotToken ()).user (id ));
468+
469+ return res .getUser ().isDeleted ();
470+ } catch (SlackApiException e ) {
471+ return true ;
472+ } catch (IOException e ) {
473+ e .printStackTrace ();
474+ return true ;
475+ }
476+ }
477+
463478 private String getSlackChannel () {
464479 String id = this .plugin .getConfig ().getString ("settings.slack-link.channel-id" );
465480
You can’t perform that action at this time.
0 commit comments