Make it buildable and reduce complexity

This commit is contained in:
2025-04-09 09:03:07 +02:00
parent 4c6ab2c1a0
commit 038f54c3b3
3 changed files with 12 additions and 8 deletions
@@ -32,7 +32,7 @@ public class ChecklistChannel extends DiscordChannel {
private final List<Integer> lastSchematics = new ArrayList<>();
public ChecklistChannel(String channel) {
super(channel);
super(channel, 0);
}
public void update() {
@@ -68,8 +68,16 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
public DiscordChannel(MessageChannel channel, int maxNumberOfWebhooks) {
this(maxNumberOfWebhooks, SteamwarUser.get(-1), channel);
ChannelListener.getChannels().put(this.channel, this);
if (channel instanceof TextChannel) {
webhooks.addAll(((TextChannel) channel).retrieveWebhooks().complete());
TextChannel textChannel = (TextChannel) channel;
webhooks.addAll(textChannel.retrieveWebhooks().complete());
while (webhooks.size() > maxNumberOfWebhooks) {
webhooks.remove().delete().queue();
}
while (webhooks.size() < maxNumberOfWebhooks) {
webhooks.add(textChannel.createWebhook(DiscordBot.getInstance().getJda().getSelfUser().getName()).complete());
}
}
}
@@ -102,10 +110,6 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
avatarUrl = DiscordBot.getInstance().getJda().getSelfUser().getAvatarUrl();
}
TextChannel textChannel = (TextChannel) getChannel();
if (webhooks.size() < maxNumberOfWebhooks) {
webhooks.add(textChannel.createWebhook(DiscordBot.getInstance().getJda().getSelfUser().getName() + "_" + webhooks.size()).complete());
}
Webhook webhook = webhooks.poll();
webhooks.add(webhook);
@@ -46,14 +46,14 @@ public class StaticMessageChannel extends DiscordChannel {
}
public StaticMessageChannel(String channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
super(channel);
super(channel, 0);
this.supplier = supplier;
this.interaction = interaction;
init();
}
public StaticMessageChannel(MessageChannel channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
super(channel);
super(channel, 0);
this.supplier = supplier;
this.interaction = interaction;
init();