mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add shorthand months
This commit is contained in:
+30
-14
@@ -1,14 +1,30 @@
|
||||
[
|
||||
"january",
|
||||
"february",
|
||||
"march",
|
||||
"april",
|
||||
"may",
|
||||
"june",
|
||||
"july",
|
||||
"august",
|
||||
"september",
|
||||
"october",
|
||||
"november",
|
||||
"december"
|
||||
]
|
||||
{
|
||||
"months": [
|
||||
"january",
|
||||
"february",
|
||||
"march",
|
||||
"april",
|
||||
"may",
|
||||
"june",
|
||||
"july",
|
||||
"august",
|
||||
"september",
|
||||
"october",
|
||||
"november",
|
||||
"december"
|
||||
],
|
||||
"shorthand": [
|
||||
"jan",
|
||||
"feb",
|
||||
"mar",
|
||||
"apr",
|
||||
"may",
|
||||
"jun",
|
||||
"jul",
|
||||
"aug",
|
||||
"sep",
|
||||
"oct",
|
||||
"nov",
|
||||
"dec"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { list, firstUpperCase } = require('../../util/Util');
|
||||
const months = require('../../assets/json/month');
|
||||
const { months } = require('../../assets/json/month');
|
||||
const stones = require('../../assets/json/birthstone');
|
||||
|
||||
module.exports = class BirthstoneCommand extends Command {
|
||||
|
||||
@@ -2,7 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { firstUpperCase, isLeap } = require('../../util/Util');
|
||||
const monthsWith30 = [4, 6, 9, 11];
|
||||
const months = require('../../assets/json/month');
|
||||
const { months } = require('../../assets/json/month');
|
||||
|
||||
module.exports = class CalendarCommand extends Command {
|
||||
constructor(client) {
|
||||
|
||||
+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