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

Commit

Permalink
Help Get error
Browse files Browse the repository at this point in the history
  • Loading branch information
duplexsystem committed Feb 9, 2021
1 parent d1f47af commit 89da0b2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/java/org/yatopiamc/bot/captcha/YatoCaptcha.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yatopiamc.bot.timings.TimingsMessageListener;

import javax.imageio.ImageIO;
import java.awt.*;
Expand All @@ -18,16 +21,19 @@
import java.util.HashMap;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public class YatoCaptcha extends ListenerAdapter {

private static final Logger LOGGER = LoggerFactory.getLogger(TimingsMessageListener.class);
private static final HashMap<User, String> codes = new HashMap<>();
private static TextChannel helpChannel = null;

private static InputStream generateImage(User u) {
InputStream is = null;
try {
final BufferedImage image = ImageIO.read(Objects.requireNonNull(ClassLoader.getSystemClassLoader().getResourceAsStream("yatopialogo.png")));
final String code = String.valueOf(new Random().nextInt(1000000 - 50000) + 50000);
final String code = String.valueOf(ThreadLocalRandom.current().nextInt(1000000 - 50000) + 50000);

Graphics2D g = (Graphics2D) image.getGraphics();
g.setFont(Font.createFont(Font.TRUETYPE_FONT, Objects.requireNonNull(ClassLoader.getSystemClassLoader().getResourceAsStream("LoveBaby.ttf"))).deriveFont(40f));
Expand All @@ -42,7 +48,8 @@ private static InputStream generateImage(User u) {
is = new ByteArrayInputStream(os.toByteArray());
os.close();
codes.put(u, code);
} catch (Exception ignored) {
} catch (Exception e) {
LOGGER.error(String.valueOf(e));
}
return is;
}
Expand Down Expand Up @@ -73,6 +80,7 @@ public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
}

public void onReady(ReadyEvent e) {
helpChannel = e.getJDA().getTextChannelById("808517832408301598");
LOGGER.warn("test");
helpChannel = e.getJDA().getTextChannelById("808517832408301598");
}
}

0 comments on commit 89da0b2

Please sign in to comment.