File tree 1 file changed +18
-0
lines changed
src/main/java/net/clementraynaud/skoice/listeners/session
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 26
26
import net .dv8tion .jda .api .Permission ;
27
27
import net .dv8tion .jda .api .entities .Guild ;
28
28
import net .dv8tion .jda .api .events .session .ReadyEvent ;
29
+ import net .dv8tion .jda .api .exceptions .ErrorResponseException ;
29
30
import net .dv8tion .jda .api .hooks .ListenerAdapter ;
31
+ import net .dv8tion .jda .api .requests .ErrorResponse ;
32
+ import net .dv8tion .jda .api .requests .RestAction ;
30
33
import net .kyori .adventure .text .event .HoverEvent ;
31
34
import org .bukkit .entity .Player ;
32
35
36
+ import java .util .function .Consumer ;
37
+
33
38
public class ReadyListener extends ListenerAdapter {
34
39
35
40
private final Skoice plugin ;
@@ -56,6 +61,19 @@ public void onReady(ReadyEvent event) {
56
61
57
62
this .setup (tokenManager );
58
63
});
64
+
65
+ Consumer <? super Throwable > defaultFailure = RestAction .getDefaultFailure ();
66
+ RestAction .setDefaultFailure (throwable -> {
67
+ if (throwable instanceof ErrorResponseException ) {
68
+ ErrorResponseException error = (ErrorResponseException ) throwable ;
69
+ if (error .getErrorCode () == ErrorResponse .MFA_NOT_ENABLED .getCode ()) {
70
+ this .plugin .getListenerManager ().update ();
71
+ return ;
72
+ }
73
+ }
74
+
75
+ defaultFailure .accept (throwable );
76
+ });
59
77
}
60
78
61
79
private void handlePublicBot (Player tokenManager ) {
You can’t perform that action at this time.
0 commit comments