Allow expiry timestamp for temporary assignment args
This commit is contained in:
parent
6451175d0e
commit
98b56691dd
@ -54,12 +54,16 @@ public class GroupSetTempInherit extends SubCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long duration;
|
long duration;
|
||||||
|
try {
|
||||||
|
duration = Long.parseLong(args.get(1));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
try {
|
try {
|
||||||
duration = DateUtil.parseDateDiff(args.get(1), true);
|
duration = DateUtil.parseDateDiff(args.get(1), true);
|
||||||
} catch (DateUtil.IllegalDateException e) {
|
} catch (DateUtil.IllegalDateException e1) {
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(1));
|
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(1));
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
if (DateUtil.shouldExpire(duration)) {
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
Message.PAST_DATE_ERROR.send(sender);
|
||||||
|
@ -68,12 +68,16 @@ public class GroupSetTempPermission extends SubCommand<Group> {
|
|||||||
boolean b = Boolean.parseBoolean(bool);
|
boolean b = Boolean.parseBoolean(bool);
|
||||||
|
|
||||||
long duration;
|
long duration;
|
||||||
|
try {
|
||||||
|
duration = Long.parseLong(args.get(2));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
try {
|
try {
|
||||||
duration = DateUtil.parseDateDiff(args.get(2), true);
|
duration = DateUtil.parseDateDiff(args.get(2), true);
|
||||||
} catch (DateUtil.IllegalDateException e) {
|
} catch (DateUtil.IllegalDateException e1) {
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
if (DateUtil.shouldExpire(duration)) {
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
Message.PAST_DATE_ERROR.send(sender);
|
||||||
|
@ -55,12 +55,17 @@ public class UserAddTempGroup extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long duration;
|
long duration;
|
||||||
|
|
||||||
|
try {
|
||||||
|
duration = Long.parseLong(args.get(1));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
try {
|
try {
|
||||||
duration = DateUtil.parseDateDiff(args.get(1), true);
|
duration = DateUtil.parseDateDiff(args.get(1), true);
|
||||||
} catch (DateUtil.IllegalDateException e) {
|
} catch (DateUtil.IllegalDateException e1) {
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(1));
|
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(1));
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
if (DateUtil.shouldExpire(duration)) {
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
Message.PAST_DATE_ERROR.send(sender);
|
||||||
|
@ -68,12 +68,16 @@ public class UserSetTempPermission extends SubCommand<User> {
|
|||||||
boolean b = Boolean.parseBoolean(bool);
|
boolean b = Boolean.parseBoolean(bool);
|
||||||
|
|
||||||
long duration;
|
long duration;
|
||||||
|
try {
|
||||||
|
duration = Long.parseLong(args.get(2));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
try {
|
try {
|
||||||
duration = DateUtil.parseDateDiff(args.get(2), true);
|
duration = DateUtil.parseDateDiff(args.get(2), true);
|
||||||
} catch (DateUtil.IllegalDateException e) {
|
} catch (DateUtil.IllegalDateException e1) {
|
||||||
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
Message.ILLEGAL_DATE_ERROR.send(sender, args.get(2));
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (DateUtil.shouldExpire(duration)) {
|
if (DateUtil.shouldExpire(duration)) {
|
||||||
Message.PAST_DATE_ERROR.send(sender);
|
Message.PAST_DATE_ERROR.send(sender);
|
||||||
|
Loading…
Reference in New Issue
Block a user