impl a EmbedDescriptionBuilder
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 38s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 38s
This commit is contained in:
parent
4f975ab07a
commit
317eaaec8a
@ -0,0 +1,40 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
public class EmbedDescriptionBuilder {
|
||||
/**
|
||||
* Where the description is stored
|
||||
*/
|
||||
private final StringBuilder builder = new StringBuilder();
|
||||
|
||||
public EmbedDescriptionBuilder(String title) {
|
||||
builder.append("**").append(title).append("**").append("\n");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public EmbedDescriptionBuilder appendLine(@NonNull String line, boolean arrow) {
|
||||
builder.append(arrow ? "➜ " : "").append(line).append("\n");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public EmbedDescriptionBuilder appendSubtitle(@NonNull String title) {
|
||||
builder.append("**").append(title).append("**").append("\n");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public EmbedDescriptionBuilder emptyLine() {
|
||||
builder.append("\n");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String build() {
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.common.NumberFormatter;
|
||||
import cc.fascinated.bat.common.TimeUtils;
|
||||
@ -42,15 +43,16 @@ public class BotStatsCommand extends BatCommand {
|
||||
JDA jda = DiscordService.JDA;
|
||||
|
||||
event.replyEmbeds(EmbedUtils.genericEmbed().setDescription(
|
||||
"**Bot Statistics**\n" +
|
||||
"➜ Guilds: **%s**\n".formatted(NumberFormatter.format(jda.getGuilds().size())) +
|
||||
"➜ Users: **%s**\n".formatted(NumberFormatter.format(jda.getUsers().size())) +
|
||||
"➜ Gateway Ping: **%sms**\n".formatted(jda.getGatewayPing()) +
|
||||
"\n" +
|
||||
"**Bat Statistics**\n" +
|
||||
"➜ Uptime: **%s**\n".formatted(TimeUtils.format(bean.getUptime())) +
|
||||
"➜ Cached Guilds: **%s**\n".formatted(NumberFormatter.format(guildService.getGuilds().size())) +
|
||||
"➜ Cached Users: **%s**".formatted(NumberFormatter.format(userService.getUsers().size()))
|
||||
new EmbedDescriptionBuilder("Bat Statistics")
|
||||
.appendLine("Guilds: **%s**".formatted(NumberFormatter.format(jda.getGuilds().size())), true)
|
||||
.appendLine("Users: **%s**".formatted(NumberFormatter.format(jda.getUsers().size())), true)
|
||||
.appendLine("Gateway Ping: **%sms**".formatted(jda.getGatewayPing()), true)
|
||||
.emptyLine()
|
||||
.appendSubtitle("Bot Statistics")
|
||||
.appendLine("Uptime: **%s**".formatted(TimeUtils.format(bean.getUptime())), true)
|
||||
.appendLine("Cached Guilds: **%s**".formatted(NumberFormatter.format(guildService.getGuilds().size())), true)
|
||||
.appendLine("Cached Users: **%s**".formatted(NumberFormatter.format(userService.getUsers().size())), true)
|
||||
.build()
|
||||
).build()).queue();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,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.EmbedDescriptionBuilder;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.common.PasteUtils;
|
||||
import cc.fascinated.bat.features.messagesnipe.MessageSnipeFeature;
|
||||
@ -32,23 +33,13 @@ public class DeletedSubCommand extends BatSubCommand {
|
||||
}
|
||||
|
||||
User author = message.getMessage().getAuthor();
|
||||
String content = message.getMessage().getContentDisplay();
|
||||
String content = message.getMessage().getContentStripped();
|
||||
String formattedContent = content.length() > 512 ? PasteUtils.uploadPaste(content).getUrl() : "```\n%s\n```".formatted(content);
|
||||
event.replyEmbeds(EmbedUtils.genericEmbed()
|
||||
.setDescription("""
|
||||
**Deleted Message Snipe**
|
||||
➜ Author: **%s** (%s)
|
||||
➜ Deleted: <t:%d:R>
|
||||
➜ Content: %s
|
||||
""".formatted(
|
||||
author.getAsMention(),
|
||||
author.getId(),
|
||||
message.getDeletedDate().getTime() / 1000,
|
||||
content.length() > 512 ? PasteUtils.uploadPaste(content).getUrl() :
|
||||
"""
|
||||
```
|
||||
%s
|
||||
```
|
||||
""".formatted(content)
|
||||
)).build()).queue();
|
||||
.setDescription(new EmbedDescriptionBuilder("Deleted Message Snipe")
|
||||
.appendLine("Author: **%s** (%s)".formatted(author.getAsMention(), author.getId()), true)
|
||||
.appendLine("Deleted: <t:%d:R>".formatted(message.getDeletedDate().getTime() / 1000), true)
|
||||
.appendLine("Content: %s".formatted(formattedContent), true)
|
||||
.build()).build()).queue();
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class DiscordMessageService extends ListenerAdapter {
|
||||
event.getChannel().getId(),
|
||||
event.getGuild().getId(),
|
||||
event.getAuthor().getId(),
|
||||
event.getMessage().getContentRaw(),
|
||||
event.getMessage().getContentStripped(),
|
||||
false
|
||||
));
|
||||
}
|
||||
@ -68,10 +68,10 @@ public class DiscordMessageService extends ListenerAdapter {
|
||||
Optional<DiscordMessage> message = discordMessageRepository.findById(event.getMessageId());
|
||||
if (message.isPresent()) {
|
||||
DiscordMessage discordMessage = message.get();
|
||||
if (discordMessage.getContent().equals(event.getMessage().getContentRaw())) {
|
||||
if (discordMessage.getContent().equals(event.getMessage().getContentStripped())) {
|
||||
return;
|
||||
}
|
||||
discordMessage.setContent(event.getMessage().getContentRaw());
|
||||
discordMessage.setContent(event.getMessage().getContentStripped());
|
||||
discordMessageRepository.save(discordMessage);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user