Skip to content
This repository was archived by the owner on Jun 19, 2021. It is now read-only.

Commit 89da0b2

Browse files
committed
Help Get error
1 parent d1f47af commit 89da0b2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/org/yatopiamc/bot/captcha/YatoCaptcha.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
88
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
99
import net.dv8tion.jda.api.hooks.ListenerAdapter;
10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
12+
import org.yatopiamc.bot.timings.TimingsMessageListener;
1013

1114
import javax.imageio.ImageIO;
1215
import java.awt.*;
@@ -18,16 +21,19 @@
1821
import java.util.HashMap;
1922
import java.util.Objects;
2023
import java.util.Random;
24+
import java.util.concurrent.ThreadLocalRandom;
2125

2226
public class YatoCaptcha extends ListenerAdapter {
27+
28+
private static final Logger LOGGER = LoggerFactory.getLogger(TimingsMessageListener.class);
2329
private static final HashMap<User, String> codes = new HashMap<>();
2430
private static TextChannel helpChannel = null;
2531

2632
private static InputStream generateImage(User u) {
2733
InputStream is = null;
2834
try {
2935
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);
3137

3238
Graphics2D g = (Graphics2D) image.getGraphics();
3339
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) {
4248
is = new ByteArrayInputStream(os.toByteArray());
4349
os.close();
4450
codes.put(u, code);
45-
} catch (Exception ignored) {
51+
} catch (Exception e) {
52+
LOGGER.error(String.valueOf(e));
4653
}
4754
return is;
4855
}
@@ -73,6 +80,7 @@ public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
7380
}
7481

7582
public void onReady(ReadyEvent e) {
76-
helpChannel = e.getJDA().getTextChannelById("808517832408301598");
83+
LOGGER.warn("test");
84+
helpChannel = e.getJDA().getTextChannelById("808517832408301598");
7785
}
7886
}

0 commit comments

Comments
 (0)