Archiviert
1
0

Remove massive resend

Dieser Commit ist enthalten in:
yoyosource 2021-07-29 16:56:58 +02:00
Ursprung a0482c8867
Commit a8d00de1e2
4 geänderte Dateien mit 30 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -47,7 +47,7 @@ public class EventManager {
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.EVENTS_CHANNEL);
assert textChannel != null;
if(textChannel.hasLatestMessage()) {
textChannel.getIterableHistory().complete().forEach(message -> message.delete().complete());
message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
}
}

Datei anzeigen

@ -21,22 +21,26 @@ package de.steamwar.bungeecore.bot.util;
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import lombok.experimental.UtilityClass;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
import net.dv8tion.jda.api.requests.restaction.MessageAction;
import java.util.ArrayList;
import java.util.List;
@UtilityClass
public class DiscordRolesMessage {
public static void sendMessage() {
public void sendMessage() {
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL);
assert channel != null;
Message message = null;
if(channel.hasLatestMessage()) {
channel.getIterableHistory().complete().forEach(message -> message.delete().complete());
message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
}
MessageBuilder builder = new MessageBuilder();
@ -45,7 +49,10 @@ public class DiscordRolesMessage {
SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton()));
builder.setActionRows(ActionRow.of(buttons));
MessageAction message = channel.sendMessage(builder.build());
message.complete();
if (message != null) {
message.editMessage(builder.build()).complete();
} else {
channel.sendMessage(builder.build()).complete();
}
}
}

Datei anzeigen

@ -24,6 +24,8 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.Emoji;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
@ -37,8 +39,9 @@ public class DiscordRulesMessage {
public static void sendMessage() {
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.RULES_CHANNEL);
assert channel != null;
Message message = null;
if(channel.hasLatestMessage()) {
channel.getIterableHistory().complete().forEach(message -> message.delete().complete());
message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
}
EmbedBuilder builder = new EmbedBuilder();
@ -55,6 +58,10 @@ public class DiscordRulesMessage {
MessageBuilder messageBuilder = new MessageBuilder();
messageBuilder.setEmbeds(builder.build());
messageBuilder.setActionRows(ActionRow.of(buttons), ActionRow.of(authButton));
if (message != null) {
message.editMessage(messageBuilder.build()).complete();
} else {
channel.sendMessage(messageBuilder.build()).complete();
}
}
}

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
@ -36,8 +37,9 @@ public class DiscordTicketMessage {
public static void sendMessage() {
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.TICKET_CHANNEL);
assert channel != null;
Message message = null;
if(channel.hasLatestMessage()) {
channel.getIterableHistory().complete().forEach(message -> message.delete().complete());
message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
}
EmbedBuilder builder = new EmbedBuilder();
@ -51,6 +53,10 @@ public class DiscordTicketMessage {
MessageBuilder messageBuilder = new MessageBuilder();
messageBuilder.setEmbeds(builder.build());
messageBuilder.setActionRows(ActionRow.of(buttons));
if (message != null) {
message.editMessage(messageBuilder.build()).complete();
} else {
channel.sendMessage(messageBuilder.build()).complete();
}
}
}