diff options
Diffstat (limited to 'src/main/java/net/tylermurphy/ken/command/moderation/TempBan.java')
-rw-r--r-- | src/main/java/net/tylermurphy/ken/command/moderation/TempBan.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/net/tylermurphy/ken/command/moderation/TempBan.java b/src/main/java/net/tylermurphy/ken/command/moderation/TempBan.java index 62696ad..f56b9ac 100644 --- a/src/main/java/net/tylermurphy/ken/command/moderation/TempBan.java +++ b/src/main/java/net/tylermurphy/ken/command/moderation/TempBan.java @@ -31,7 +31,7 @@ public class TempBan { @Option(name="days", description="Days for temp ban", type= OptionType.INTEGER, required=true) @Option(name="hours", description="Hours for temp ban", type= OptionType.INTEGER, required=true) @Option(name="reason", description="Reason to temp-ban", type=OptionType.STRING, required=true) - @Option(name="deletemessages", description="Delete messages from past 24h", type=OptionType.BOOLEAN, required=true) + @Option(name="delete_messages", description="Delete messages from past 24h", type=OptionType.BOOLEAN, required=true) @Requirement(Permission.BAN_MEMBERS) public Response execute(Member sender, List<Object> args, Guild guild){ Member target = (Member) args.get(0); @@ -51,6 +51,9 @@ public class TempBan { if(!Checks.getRolePermission(self, low)){ return Response.error("I need a higher role than the target"); } + if(guild.getOwner() == target){ + return Response.error("You cannot to this to the server owner"); + } if(hours < 0){ return Response.error("Hours must be 0 or greater"); } @@ -70,7 +73,7 @@ public class TempBan { cal.setTime(new Date()); cal.add(Calendar.DATE, days); cal.add(Calendar.HOUR, hours); - SimpleDateFormat format = new SimpleDateFormat("L d, y ha zz"); + SimpleDateFormat format = new SimpleDateFormat("MMM d, y ha zz"); String date = format.format(cal.getTime()); ModerationTable table = Ken.getInstance().getDatabase().getModerationTable(); @@ -89,6 +92,8 @@ public class TempBan { table.setData(guild.getIdLong(), target.getUser().getIdLong(), json.toString()); + Ken.getInstance().getDatabase().getUserTable().setData(target.getIdLong(), target.getUser().getName(), Integer.parseInt(target.getUser().getDiscriminator())); + PrivateChannel channel = target.getUser().openPrivateChannel().complete(); if(channel != null){ EmbedBuilder builder = Ken.getInstance().getDefaultEmbed() @@ -96,13 +101,13 @@ public class TempBan { .setTitle("**Temp Banned**") .appendDescription("You have been temporarily banned from "+guild.getName()+"\n") .appendDescription("`By:` " + sender.getEffectiveName()+"\n") - .appendDescription("`Reason:` " + reason) + .appendDescription("`Reason:` " + reason+"\n") .appendDescription("`Until:` " + date); channel.sendMessageEmbeds(builder.build()).queue(); } guild.ban(target,purge ? 1 : 0,reason).queue(); EmbedBuilder builder = Ken.getInstance().getDefaultEmbed() - .appendDescription(String.format("Temporarily banned %s for %s until %s", target.getEffectiveName(), reason, date)); + .appendDescription(String.format("Temporarily banned %s for %s until %s", target, reason, date)); return Response.success(builder.build()); } |