Skip to content

Commit 01e1f55

Browse files
committed
Fixed autotagging nuking old tags
1 parent 606c398 commit 01e1f55

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/main/java/xyz/htmlcsjs/coffeeFloppa/handlers/MessageHandler.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import discord4j.core.object.reaction.ReactionEmoji;
1313
import discord4j.core.spec.MessageCreateFields;
1414
import discord4j.core.spec.MessageCreateMono;
15+
import discord4j.discordjson.Id;
1516
import discord4j.discordjson.json.EmojiData;
1617
import discord4j.rest.route.Routes;
1718
import discord4j.rest.util.AllowedMentions;
@@ -146,9 +147,13 @@ public static Mono<Object> threadCreate(ThreadChannelCreateEvent event) {
146147
Snowflake parentId = thread.getParentId().orElse(null);
147148
if (parentId != null && parentId.equals(Snowflake.of(FloppaTomlConfig.autoTagChannel))) {
148149
// i love APIs
149-
CoffeeFloppa.client.getChannelService();
150+
List<Id> tags = new ArrayList<>();
151+
if (!thread.getData().appliedTags().isAbsent()) {
152+
tags.addAll(thread.getData().appliedTags().get());
153+
}
154+
tags.add(Id.of(FloppaTomlConfig.autoTagId));
150155
return Routes.CHANNEL_MODIFY_PARTIAL.newRequest(thread.getId().asLong())
151-
.body(new AddTagEditRequest(FloppaTomlConfig.autoTagId))
156+
.body(new AddTagEditRequest(tags))
152157
.optionalHeader("X-Audit-Log-Reason", "Floppa Automated")
153158
.exchange(CoffeeFloppa.client.getRestResources().getRouter())
154159
.bodyToMono(Object.class);
@@ -275,10 +280,10 @@ public static String getCurrentMessageURL() {
275280

276281
private static class AddTagEditRequest {
277282
@JsonProperty("applied_tags")
278-
private final List<Long> appliedTags;
283+
private final List<Id> appliedTags;
279284

280-
protected AddTagEditRequest(Long... tags) {
281-
this.appliedTags = List.of(tags);
285+
protected AddTagEditRequest(List<Id> tags) {
286+
this.appliedTags = tags;
282287
}
283288
}
284289
}

0 commit comments

Comments
 (0)