Merge remote-tracking branch 'origin/master'

# Conflicts:
#	KilluaBot.iml
#	src/main/java/com/github/nilstrieb/commands/util/EmoteAddCommand.java
This commit is contained in:
nora 2021-05-06 19:24:29 +02:00
commit a1e8571b06
2 changed files with 5 additions and 33 deletions

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_14">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: net.dv8tion:JDA:4.2.0_168" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:16.0.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: com.neovisionaries:nv-websocket-client:2.9" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.13.0" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
<orderEntry type="library" name="Maven: club.minnced:opus-java-api:1.0.4" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: net.java.dev.jna:jna:4.4.0" level="project" />
<orderEntry type="library" name="Maven: club.minnced:opus-java-natives:1.0.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.1" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
</component>
</module>

View file

@ -12,8 +12,9 @@ import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
import java.net.URL; import java.net.URL;
import java.util.Arrays; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class EmoteAddCommand extends Command { public class EmoteAddCommand extends Command {
@ -107,7 +108,7 @@ public class EmoteAddCommand extends Command {
private boolean emoteLimitReached() { private boolean emoteLimitReached() {
int max = event.getGuild().getMaxEmotes(); int max = event.getGuild().getMaxEmotes();
int count = event.getGuild().retrieveEmotes().complete().size(); int count = (int) event.getGuild().retrieveEmotes().complete().stream().filter(e -> !e.isAnimated()).count();
return max == count; return max == count;
} }
@ -115,8 +116,8 @@ public class EmoteAddCommand extends Command {
private byte[] resizeImage(byte[] bytes, String format, int size) throws IOException { private byte[] resizeImage(byte[] bytes, String format, int size) throws IOException {
reply("Image size too big (" + bytes.length / 1000 + "kB). Resizing image..."); reply("Image size too big (" + bytes.length / 1000 + "kB). Resizing image...");
Image image = ImageIO.read(new ByteArrayInputStream(bytes)); Image image = ImageIO.read(new ByteArrayInputStream(bytes));
double ratio = (double)image.getHeight(null) / (double)image.getWidth(null); int ratio = image.getHeight(null) / image.getWidth(null);
image = image.getScaledInstance(size, (int) (size * ratio), Image.SCALE_SMOOTH); image = image.getScaledInstance(size, size * ratio, Image.SCALE_SMOOTH);
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedImage bufferedImg = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); BufferedImage bufferedImg = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);