forked from SteamWar/SteamWar
Make it buildable and reduce complexity
This commit is contained in:
@@ -32,7 +32,7 @@ public class ChecklistChannel extends DiscordChannel {
|
|||||||
private final List<Integer> lastSchematics = new ArrayList<>();
|
private final List<Integer> lastSchematics = new ArrayList<>();
|
||||||
|
|
||||||
public ChecklistChannel(String channel) {
|
public ChecklistChannel(String channel) {
|
||||||
super(channel);
|
super(channel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
|||||||
@@ -68,8 +68,16 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
|
|||||||
public DiscordChannel(MessageChannel channel, int maxNumberOfWebhooks) {
|
public DiscordChannel(MessageChannel channel, int maxNumberOfWebhooks) {
|
||||||
this(maxNumberOfWebhooks, SteamwarUser.get(-1), channel);
|
this(maxNumberOfWebhooks, SteamwarUser.get(-1), channel);
|
||||||
ChannelListener.getChannels().put(this.channel, this);
|
ChannelListener.getChannels().put(this.channel, this);
|
||||||
|
|
||||||
if (channel instanceof TextChannel) {
|
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();
|
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();
|
Webhook webhook = webhooks.poll();
|
||||||
webhooks.add(webhook);
|
webhooks.add(webhook);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -46,14 +46,14 @@ public class StaticMessageChannel extends DiscordChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StaticMessageChannel(String channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
|
public StaticMessageChannel(String channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
|
||||||
super(channel);
|
super(channel, 0);
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
this.interaction = interaction;
|
this.interaction = interaction;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticMessageChannel(MessageChannel channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
|
public StaticMessageChannel(MessageChannel channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
|
||||||
super(channel);
|
super(channel, 0);
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
this.interaction = interaction;
|
this.interaction = interaction;
|
||||||
init();
|
init();
|
||||||
|
|||||||
Reference in New Issue
Block a user