7
7
import net .dv8tion .jda .api .events .guild .member .GuildMemberJoinEvent ;
8
8
import net .dv8tion .jda .api .events .message .priv .PrivateMessageReceivedEvent ;
9
9
import net .dv8tion .jda .api .hooks .ListenerAdapter ;
10
+ import org .slf4j .Logger ;
11
+ import org .slf4j .LoggerFactory ;
12
+ import org .yatopiamc .bot .timings .TimingsMessageListener ;
10
13
11
14
import javax .imageio .ImageIO ;
12
15
import java .awt .*;
18
21
import java .util .HashMap ;
19
22
import java .util .Objects ;
20
23
import java .util .Random ;
24
+ import java .util .concurrent .ThreadLocalRandom ;
21
25
22
26
public class YatoCaptcha extends ListenerAdapter {
27
+
28
+ private static final Logger LOGGER = LoggerFactory .getLogger (TimingsMessageListener .class );
23
29
private static final HashMap <User , String > codes = new HashMap <>();
24
30
private static TextChannel helpChannel = null ;
25
31
26
32
private static InputStream generateImage (User u ) {
27
33
InputStream is = null ;
28
34
try {
29
35
final BufferedImage image = ImageIO .read (Objects .requireNonNull (ClassLoader .getSystemClassLoader ().getResourceAsStream ("yatopialogo.png" )));
30
- final String code = String .valueOf (new Random ().nextInt (1000000 - 50000 ) + 50000 );
36
+ final String code = String .valueOf (ThreadLocalRandom . current ().nextInt (1000000 - 50000 ) + 50000 );
31
37
32
38
Graphics2D g = (Graphics2D ) image .getGraphics ();
33
39
g .setFont (Font .createFont (Font .TRUETYPE_FONT , Objects .requireNonNull (ClassLoader .getSystemClassLoader ().getResourceAsStream ("LoveBaby.ttf" ))).deriveFont (40f ));
@@ -42,7 +48,8 @@ private static InputStream generateImage(User u) {
42
48
is = new ByteArrayInputStream (os .toByteArray ());
43
49
os .close ();
44
50
codes .put (u , code );
45
- } catch (Exception ignored ) {
51
+ } catch (Exception e ) {
52
+ LOGGER .error (String .valueOf (e ));
46
53
}
47
54
return is ;
48
55
}
@@ -73,6 +80,7 @@ public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
73
80
}
74
81
75
82
public void onReady (ReadyEvent e ) {
76
- helpChannel = e .getJDA ().getTextChannelById ("808517832408301598" );
83
+ LOGGER .warn ("test" );
84
+ helpChannel = e .getJDA ().getTextChannelById ("808517832408301598" );
77
85
}
78
86
}
0 commit comments