Skip to content

Commit 9286d77

Browse files
committed
Re-interrupt the thread on attachment failure and remove attachedImage variable
1 parent 60529d6 commit 9286d77

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/main/java/net/javadiscord/javabot/systems/starboard/StarboardManager.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ private void addMessageToStarboard(Message message, int stars, @NotNull Starboar
149149
action.addFiles(FileUpload.fromData(a.getProxy().download().get(), a.getFileName()));
150150
} catch (InterruptedException | ExecutionException e) {
151151
action.addContent("Could not add Attachment: " + a.getFileName());
152+
ExceptionLogger.capture(e);
153+
if(e instanceof InterruptedException) {
154+
Thread.currentThread().interrupt();
155+
}
152156
}
153157
}
154158
}
@@ -231,8 +235,6 @@ private boolean removeMessageFromStarboard(long messageId, MessageChannel channe
231235
.setDescription(message.getContentRaw())
232236
.setFooter("#" + message.getChannel().getName());
233237

234-
boolean attachedImage = false;
235-
236238
List<MessageEmbed> embeds = message.getEmbeds();
237239
if(embeds.size() > 0) {
238240
MessageEmbed firstEmbed = embeds.get(0);
@@ -242,15 +244,12 @@ private boolean removeMessageFromStarboard(long messageId, MessageChannel channe
242244
ImageInfo image = firstEmbed.getImage();
243245
if(image != null && image.getUrl() != null) {
244246
builder.setImage(image.getUrl());
245-
attachedImage = true;
246247
}
247248
}
248249

249-
if(!attachedImage) {
250-
List<Attachment> attachments = message.getAttachments();
251-
if(attachments.size() == 1) {
252-
builder.setImage(attachments.get(0).getUrl());
253-
}
250+
List<Attachment> attachments = message.getAttachments();
251+
if(attachments.size() == 1) {
252+
builder.setImage(attachments.get(0).getUrl());
254253
}
255254

256255
return builder.build();

0 commit comments

Comments
 (0)