mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
Truncate Discord interaction messages to proper length (#4686)
This commit is contained in:
parent
20a7d1c7ee
commit
840035944a
@ -3,6 +3,7 @@ package net.essentialsx.discord.interactions;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.google.common.base.Joiner;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionChannel;
|
||||
@ -33,7 +34,7 @@ public class InteractionEventImpl implements InteractionEvent {
|
||||
public void reply(String message) {
|
||||
message = FormatUtil.stripFormat(message).replace("§", ""); // Don't ask
|
||||
replyBuffer.add(message);
|
||||
event.getHook().editOriginal(new MessageBuilder().setContent(Joiner.on('\n').join(replyBuffer)).setAllowedMentions(DiscordUtil.NO_GROUP_MENTIONS).build())
|
||||
event.getHook().editOriginal(new MessageBuilder().setContent(Joiner.on('\n').join(replyBuffer).substring(0, Message.MAX_CONTENT_LENGTH)).setAllowedMentions(DiscordUtil.NO_GROUP_MENTIONS).build())
|
||||
.queue(null, error -> logger.log(Level.SEVERE, "Error while editing command interaction response", error));
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@ public class ConsoleInjector extends AbstractAppender {
|
||||
entry = "[" + event.getLoggerName() + "] " + entry;
|
||||
}
|
||||
|
||||
//noinspection UnstableApiUsage
|
||||
messageQueue.addAll(Splitter.fixedLength(Message.MAX_CONTENT_LENGTH - 2).splitToList(
|
||||
MessageUtil.formatMessage(jda.getSettings().getConsoleFormat(),
|
||||
TimeFormat.TIME_LONG.format(Instant.now()),
|
||||
|
Loading…
Reference in New Issue
Block a user