diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java index fecb38d..3e48e90 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java @@ -59,9 +59,9 @@ return; } int minutes; - if(args.time < 0) + if(args.time < -1) throw new CommandErrorException("Timed bans cannot be negative time!"); - else if(args.time == 0) + else if(args.time == -1) minutes = 0; else if(args.time > 60) minutes = (int)Math.round(args.time/60.0); diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java index 0962a5b..bac0fac 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java @@ -73,9 +73,9 @@ return; } int minutes; - if(args.time < 0) + if(args.time < -1) throw new CommandErrorException("Timed mutes cannot be negative time!"); - else if(args.time == 0) + else if(args.time == -1) minutes = 0; else if(args.time > 60) minutes = (int)Math.round(args.time/60.0); diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java index e77efb3..5ef6ae7 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java @@ -75,7 +75,7 @@ catch (Exception e) { time = OtherUtil.parseTime(event.getArgs()); - if (time == 0) + if (time <= 0) { event.replyError("Invalid time"); return; diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java index 6a946ca..222af98 100644 --- a/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java @@ -53,7 +53,7 @@ return; } int seconds = OtherUtil.parseTime(parts[1]); - if(seconds == 0) + if(seconds <= 0) { event.replyError("Invalid time"); return; diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java index 350317c..15fb040 100644 --- a/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java @@ -92,7 +92,18 @@ case "temp-mute": case "mute": { - int minutes = parts.length>2 ? OtherUtil.parseTime(parts[2])/60 : 0; + int minutes = 0; + if(parts.length > 2) + { + int parseResult = OtherUtil.parseTime(parts[2]); + if(parseResult == -1) + { + event.replyError("Invalid time!"); + return; + } + minutes = parseResult/60; + } + if(minutes<0) { event.replyError("Temp-Mute time cannot be negative!"); @@ -120,7 +131,18 @@ case "temp-ban": case "ban": { - int minutes = parts.length>2 ? OtherUtil.parseTime(parts[2])/60 : 0; + int minutes = 0; + if(parts.length > 2) + { + int parseResult = OtherUtil.parseTime(parts[2]); + if(parseResult == -1) + { + event.replyError("Invalid time!"); + return; + } + minutes = parseResult/60; + } + if(minutes<0) { event.replyError("Temp-Ban time cannot be negative!"); diff --git a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java index 9faab05..39c8b2e 100644 --- a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java @@ -106,7 +106,7 @@ } catch(Exception ex) { - return 0; + return -1; } return timeinseconds; }