use paste for messages longer than 512 and fix message sniping
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m10s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m10s
This commit is contained in:
@ -56,8 +56,8 @@ public class MessageSnipeFeature extends Feature implements EventListener {
|
||||
* @return the sniped messages for the given guild
|
||||
*/
|
||||
public static SnipedMessage getDeletedMessage(BatGuild guild, String channelId) {
|
||||
List<SnipedMessage> messages = snipedMessages.getOrDefault(guild, new ArrayList<>());
|
||||
messages.sort(Comparator.comparing(SnipedMessage::getDeletedDate));
|
||||
List<SnipedMessage> messages = snipedMessages.getOrDefault(guild, new ArrayList<>()).stream().filter(message -> message.getDeletedDate() != null)
|
||||
.sorted(Comparator.comparing(SnipedMessage::getDeletedDate).reversed()).toList();
|
||||
for (SnipedMessage message : messages) {
|
||||
if (message.getDeletedDate() != null // Check if the message was deleted
|
||||
&& message.getMessage().getChannel().getId().equals(channelId)) {
|
||||
|
@ -3,6 +3,7 @@ package cc.fascinated.bat.features.messagesnipe.command;
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.common.PasteUtils;
|
||||
import cc.fascinated.bat.features.messagesnipe.MessageSnipeFeature;
|
||||
import cc.fascinated.bat.features.messagesnipe.SnipedMessage;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -31,20 +32,23 @@ public class DeletedSubCommand extends BatSubCommand {
|
||||
}
|
||||
|
||||
User author = message.getMessage().getAuthor();
|
||||
String content = message.getMessage().getContentDisplay();
|
||||
event.replyEmbeds(EmbedUtils.genericEmbed()
|
||||
.setDescription("""
|
||||
**Deleted Message Snipe**
|
||||
➜ Author: **%s** (%s)
|
||||
➜ Deleted: <t:%d:R>
|
||||
➜ Content:
|
||||
```
|
||||
%s
|
||||
```
|
||||
➜ Content: %s
|
||||
""".formatted(
|
||||
author.getAsMention(),
|
||||
author.getId(),
|
||||
message.getDeletedDate().getTime() / 1000,
|
||||
message.getMessage().getContentRaw()
|
||||
content.length() > 512 ? PasteUtils.uploadPaste(content).getUrl() :
|
||||
"""
|
||||
```
|
||||
%s
|
||||
```
|
||||
""".formatted(content)
|
||||
)).build()).queue();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user