remove moment dependency
This commit is contained in:
parent
1b93be6599
commit
4001080638
5 changed files with 40 additions and 28 deletions
|
@ -1,5 +1,4 @@
|
|||
const { Client, CommandInteraction, EmbedBuilder } = require("discord.js");
|
||||
const moment = require("moment");
|
||||
const axios = require("axios");
|
||||
module.exports = {
|
||||
name: "build",
|
||||
|
@ -663,7 +662,7 @@ module.exports = {
|
|||
* @param {CommandInteraction} interaction
|
||||
* @param {String[]} args
|
||||
*/
|
||||
run: async (client, interaction, args) => {
|
||||
run: async (client, interaction, args, utils) => {
|
||||
const cwts = args[1];
|
||||
const cc = args[2];
|
||||
const tag = args[3];
|
||||
|
@ -710,8 +709,8 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
name: "<a:lastupdate:897381474330873887> Last Updated:",
|
||||
value: `\`\`\`\n${moment(Date.parse(data.lastUpdate)).format(
|
||||
"MMMM Do YYYY"
|
||||
value: `\`\`\`\n${utils.parseShortDate(
|
||||
new Date(data.lastUpdate)
|
||||
)}\n\`\`\``,
|
||||
inline: true,
|
||||
},
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const { EmbedBuilder, version: djsversion } = require("discord.js");
|
||||
const version = require("../../package.json").version;
|
||||
const { utc } = require("moment");
|
||||
module.exports = {
|
||||
name: "botinfo",
|
||||
description: "Check the info of the bot",
|
||||
|
@ -20,8 +19,8 @@ module.exports = {
|
|||
<:nyx_owner:897418259433943120> Owner ❯ <@452076196419600394>
|
||||
Bot ❯ ${client.user.tag}
|
||||
Bot ID ❯ \`${client.user.id}\`
|
||||
Created on ❯ \`${utc(client.user.createdTimestamp).format(
|
||||
"MMMM Do YYYY"
|
||||
Created on ❯ \`${utils.botDate(
|
||||
new Date(client.user.createdTimestamp)
|
||||
)}\``,
|
||||
inline: true,
|
||||
},
|
||||
|
|
|
@ -41,11 +41,10 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.1.3",
|
||||
"cath": "^1.5.0",
|
||||
"cath": "^1.5.11",
|
||||
"discord.js": "^14.9.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"goosecache": "^9.0.14",
|
||||
"moment": "^2.29.4",
|
||||
"mongoose": "^5.13.14",
|
||||
"quickchart-js": "^3.1.0"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const { EmbedBuilder } = require("discord.js");
|
||||
const moment = require("moment");
|
||||
const axios = require("axios");
|
||||
module.exports = {
|
||||
name: "stats",
|
||||
|
@ -406,7 +405,7 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
// It's not complete, Still work in progress.
|
||||
run: async (client, interaction, args) => {
|
||||
run: async (client, interaction, args, utils) => {
|
||||
const cwts = args[1];
|
||||
const data = await axios
|
||||
.get(`${process.env.api}/api/v1/codm/builds?cwts=${cwts}`, {
|
||||
|
@ -444,8 +443,8 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
name: "<a:lastupdate:897381474330873887> Last Updated:",
|
||||
value: `\`\`\`\n${moment(Date.parse(data.lastUpdate)).format(
|
||||
"MMMM Do YYYY"
|
||||
value: `\`\`\`\n${utils.parseShortDate(
|
||||
new Date(data.lastUpdate)
|
||||
)}\n\`\`\``,
|
||||
inline: true,
|
||||
},
|
||||
|
|
|
@ -11,28 +11,31 @@ const {
|
|||
Array.prototype.random = function () {
|
||||
return this[~~(Math.random() * this.length)];
|
||||
};
|
||||
|
||||
function rndint(max, min) {
|
||||
return Math.floor(Math.random() * (max - (min ? min : 0))) + (min ? min : 0);
|
||||
}
|
||||
|
||||
const months = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
];
|
||||
|
||||
function parseDate(date) {
|
||||
const months = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
];
|
||||
let dow = date.getDate().toString();
|
||||
return `${date.toLocaleDateString("en-US", {
|
||||
weekday: "long",
|
||||
})}, ${months[date.getMonth() - 1]} ${
|
||||
})}, ${months[date.getMonth()]} ${
|
||||
dow.endsWith("1")
|
||||
? `${dow}st`
|
||||
: dow.endsWith("2")
|
||||
|
@ -43,6 +46,18 @@ function parseDate(date) {
|
|||
} ${date.getFullYear()}, ${date.toLocaleTimeString()}`;
|
||||
}
|
||||
|
||||
function parseShortDate(date) {
|
||||
let dow = date.getDate().toString();
|
||||
return `${months[date.getMonth()]} ${
|
||||
dow.endsWith("1")
|
||||
? `${dow}st`
|
||||
: dow.endsWith("2")
|
||||
? `${dow}nd`
|
||||
: dow.endsWith("3")
|
||||
? `${dow}rd`
|
||||
: `${dow}th`
|
||||
} ${date.getFullYear()}`;
|
||||
}
|
||||
function timer(timestamp) {
|
||||
const timeLeft = timestamp;
|
||||
const days = Math.floor(timeLeft / 86400000);
|
||||
|
@ -794,6 +809,7 @@ function convert(value, unit, unitValues) {
|
|||
module.exports = {
|
||||
rndint,
|
||||
parseDate,
|
||||
parseShortDate,
|
||||
timer,
|
||||
sleep,
|
||||
toHHMMSS,
|
||||
|
|
Loading…
Reference in a new issue