Require reports to be at least 3 words long

This commit is contained in:
Stijn 2022-05-23 22:06:17 +02:00
parent 1946cd4ab7
commit faa0435131
2 changed files with 8 additions and 1 deletions

View File

@ -422,6 +422,7 @@ public final class Config {
public static HashMap<String, Long> serverChannelId = new HashMap<>();
public static String REPORT_SENT = "<green>Your report was sent, staff will contact you asap to help resolve your issue!</green>";
public static String REPORT_TOO_SHORT = "<red>Please ensure your report is descriptive. We require at least 3 words per report</red>";
private static void loadChannelIds() {
serverChannelId.clear();
serverChannelId.put("general", getLong("discord-channel-id.general", (long) -1));
@ -436,6 +437,7 @@ public final class Config {
serverChannelId.put(key.toLowerCase(), channelId);
}
REPORT_SENT = getString("messages.report-sent", REPORT_SENT);
REPORT_TOO_SHORT = getString("messages.report-too-short", REPORT_TOO_SHORT);
}
public static String HELP_REPORT = "<red>/report <message></red>";

View File

@ -45,6 +45,11 @@ public class Report {
if (optionalServerConnection.isEmpty()) {
return 1;
}
String report = context.getArgument("report", String.class);
if (report.split(" ").length < 3) {
player.sendMessage(Utility.parseMiniMessage(Config.REPORT_TOO_SHORT));
return 1;
}
ServerConnection serverConnection = optionalServerConnection.get();
String serverName = serverConnection.getServer().getServerInfo().getName();
@ -53,7 +58,7 @@ public class Report {
embedBuilder.setTitle("Player Report");
embedBuilder.setColor(Color.CYAN);
embedBuilder.addField("Incident",
context.getArgument("report", String.class),
report,
false);
embedBuilder.addField("Server",
serverName.substring(0, 1).toUpperCase() + serverName.substring(1),