geforkt von SteamWar/BungeeCore
Remove massive resend
Dieser Commit ist enthalten in:
Ursprung
a0482c8867
Commit
a8d00de1e2
@ -47,7 +47,7 @@ public class EventManager {
|
|||||||
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.EVENTS_CHANNEL);
|
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.EVENTS_CHANNEL);
|
||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
if(textChannel.hasLatestMessage()) {
|
if(textChannel.hasLatestMessage()) {
|
||||||
textChannel.getIterableHistory().complete().forEach(message -> message.delete().complete());
|
message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,22 +21,26 @@ package de.steamwar.bungeecore.bot.util;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
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.entities.TextChannel;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.Button;
|
||||||
import net.dv8tion.jda.api.requests.restaction.MessageAction;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
public class DiscordRolesMessage {
|
public class DiscordRolesMessage {
|
||||||
|
|
||||||
public static void sendMessage() {
|
|
||||||
|
public void sendMessage() {
|
||||||
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL);
|
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL);
|
||||||
assert channel != null;
|
assert channel != null;
|
||||||
|
Message message = null;
|
||||||
if(channel.hasLatestMessage()) {
|
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();
|
MessageBuilder builder = new MessageBuilder();
|
||||||
@ -45,7 +49,10 @@ public class DiscordRolesMessage {
|
|||||||
SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton()));
|
SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton()));
|
||||||
builder.setActionRows(ActionRow.of(buttons));
|
builder.setActionRows(ActionRow.of(buttons));
|
||||||
|
|
||||||
MessageAction message = channel.sendMessage(builder.build());
|
if (message != null) {
|
||||||
message.complete();
|
message.editMessage(builder.build()).complete();
|
||||||
|
} else {
|
||||||
|
channel.sendMessage(builder.build()).complete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
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.entities.TextChannel;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.Button;
|
||||||
@ -37,8 +39,9 @@ public class DiscordRulesMessage {
|
|||||||
public static void sendMessage() {
|
public static void sendMessage() {
|
||||||
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.RULES_CHANNEL);
|
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.RULES_CHANNEL);
|
||||||
assert channel != null;
|
assert channel != null;
|
||||||
|
Message message = null;
|
||||||
if(channel.hasLatestMessage()) {
|
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();
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
@ -55,6 +58,10 @@ public class DiscordRulesMessage {
|
|||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageBuilder messageBuilder = new MessageBuilder();
|
||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(ActionRow.of(buttons), ActionRow.of(authButton));
|
messageBuilder.setActionRows(ActionRow.of(buttons), ActionRow.of(authButton));
|
||||||
|
if (message != null) {
|
||||||
|
message.editMessage(messageBuilder.build()).complete();
|
||||||
|
} else {
|
||||||
channel.sendMessage(messageBuilder.build()).complete();
|
channel.sendMessage(messageBuilder.build()).complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
|||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
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.entities.TextChannel;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.Button;
|
||||||
@ -36,8 +37,9 @@ public class DiscordTicketMessage {
|
|||||||
public static void sendMessage() {
|
public static void sendMessage() {
|
||||||
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.TICKET_CHANNEL);
|
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.TICKET_CHANNEL);
|
||||||
assert channel != null;
|
assert channel != null;
|
||||||
|
Message message = null;
|
||||||
if(channel.hasLatestMessage()) {
|
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();
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
@ -51,6 +53,10 @@ public class DiscordTicketMessage {
|
|||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageBuilder messageBuilder = new MessageBuilder();
|
||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(ActionRow.of(buttons));
|
messageBuilder.setActionRows(ActionRow.of(buttons));
|
||||||
|
if (message != null) {
|
||||||
|
message.editMessage(messageBuilder.build()).complete();
|
||||||
|
} else {
|
||||||
channel.sendMessage(messageBuilder.build()).complete();
|
channel.sendMessage(messageBuilder.build()).complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren