tags: validate input types for timeAdd and timeSub

This commit is contained in:
Dragory 2021-09-14 01:45:15 +03:00
parent 7edfe1581a
commit c84d1a0be1
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -133,6 +133,10 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
return Date.now();
}
if (!Number.isNaN(Number(str))) {
return Number(str); // Unix timestamp as a string
}
return moment.tz(str, "YYYY-MM-DD HH:mm:ss", tz).valueOf();
},
@ -156,6 +160,14 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
let reference;
let delay;
for (const [i, arg] of args.entries()) {
if (typeof arg === "number") {
args[i] = String(arg);
} else if (typeof arg !== "string") {
args[i] = "";
}
}
if (args.length >= 2) {
// (time, delay)
reference = this.parseDateTime(args[0]);
@ -175,6 +187,14 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
let reference;
let delay;
for (const [i, arg] of args.entries()) {
if (typeof arg === "number") {
args[i] = String(arg);
} else if (typeof arg !== "string") {
args[i] = "";
}
}
if (args.length >= 2) {
// (time, delay)
reference = this.parseDateTime(args[0]);