mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Add shorthand months
This commit is contained in:
+5
-2
@@ -1,5 +1,5 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
const months = require('../assets/json/month');
|
||||
const { months, shorthand } = require('../assets/json/month');
|
||||
|
||||
module.exports = class MonthArgumentType extends ArgumentType {
|
||||
constructor(client) {
|
||||
@@ -10,12 +10,15 @@ module.exports = class MonthArgumentType extends ArgumentType {
|
||||
const num = Number.parseInt(value, 10);
|
||||
if (num > 0 && num < 13) return true;
|
||||
if (months.includes(value.toLowerCase())) return true;
|
||||
if (shorthand.includes(value.toLowerCase())) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
parse(value) {
|
||||
const num = Number.parseInt(value, 10);
|
||||
if (!Number.isNaN(num)) return num;
|
||||
return months.indexOf(value.toLowerCase()) + 1;
|
||||
if (months.includes(value.toLowerCase())) return months.indexOf(value.toLowerCase()) + 1;
|
||||
if (shorthand.includes(value.toLowerCase())) return shorthand.indexOf(value.toLowerCase()) + 1;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user