actually make it 300 because too much output crashes the bot

This commit is contained in:
Chayapak 2023-04-07 14:23:15 +07:00
parent f60cf80bcd
commit bec3908919

View file

@ -156,16 +156,25 @@ public class GrepLogPlugin {
}
private void finish () {
bot.chat().tellraw(
Component.translatable(
"Log query finished, found %s matches. Results were sent in Discord",
Component.text(matches).color(NamedTextColor.AQUA)
)
);
if (results.toString().split("\n").length < 300) { // ig lazy fix for removing \n lol
bot.chat().tellraw(
Component.empty()
.append(Component.text("Log query output:"))
.append(Component.newline())
.append(Component.text(results.toString()))
);
} else {
bot.chat().tellraw(
Component.translatable(
"Log query finished, found %s matches. Results were sent in Discord",
Component.text(matches).color(NamedTextColor.AQUA)
)
);
final String channelId = bot.discord().servers.get(bot.host() + ":" + bot.port());
final TextChannel logChannel = bot.discord().jda().getTextChannelById(channelId);
logChannel.sendMessage("Log query output").addFile(results.toString().getBytes(), "report.txt").queue();
final String channelId = bot.discord().servers.get(bot.host() + ":" + bot.port());
final TextChannel logChannel = bot.discord().jda().getTextChannelById(channelId);
logChannel.sendMessage("Log query output").addFile(results.toString().getBytes(), "report.txt").queue();
}
}
}
}