mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-31 22:54:10 +05:00
refactor: delete useless depend moment
This commit is contained in:
parent
c0f14df726
commit
c8f73bef1e
4 changed files with 6 additions and 32 deletions
|
@ -25,7 +25,6 @@
|
|||
"i18next": "^24.0.0",
|
||||
"i18next-fs-backend": "^2.6.0",
|
||||
"md5": "^2.3.0",
|
||||
"moment": "^2.29.4",
|
||||
"mongoose": "^8.8.2",
|
||||
"ms": "^2.1.3",
|
||||
"node-fetch": "^2.7.0"
|
||||
|
|
|
@ -56,9 +56,6 @@ importers:
|
|||
md5:
|
||||
specifier: ^2.3.0
|
||||
version: 2.3.0
|
||||
moment:
|
||||
specifier: ^2.29.4
|
||||
version: 2.30.1
|
||||
mongoose:
|
||||
specifier: ^8.8.2
|
||||
version: 8.8.2(socks@2.8.3)
|
||||
|
@ -1099,9 +1096,6 @@ packages:
|
|||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
|
||||
mongodb-connection-string-url@3.0.1:
|
||||
resolution: {integrity: sha512-XqMGwRX0Lgn05TDB4PyG2h2kKO/FfWJyCzYQbIhXUxz7ETt0I/FqHjUeqj37irJ+Dl1ZtU82uYyj14u2XsZKfg==}
|
||||
|
||||
|
@ -2748,8 +2742,6 @@ snapshots:
|
|||
|
||||
mkdirp@1.0.4: {}
|
||||
|
||||
moment@2.30.1: {}
|
||||
|
||||
mongodb-connection-string-url@3.0.1:
|
||||
dependencies:
|
||||
'@types/whatwg-url': 11.0.5
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
fetch = require("node-fetch"),
|
||||
moment = require("moment");
|
||||
fetch = require("node-fetch");
|
||||
|
||||
class Checkjar extends BaseCommand {
|
||||
/**
|
||||
|
@ -56,7 +55,7 @@ class Checkjar extends BaseCommand {
|
|||
jarTransactions.length = 10;
|
||||
|
||||
jarTransactions.forEach(t => {
|
||||
const time = moment.unix(t.time);
|
||||
const time = new Intl.DateTimeFormat("ru-RU").format(t.time);
|
||||
|
||||
embed.data.fields.push([
|
||||
{
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import moment from "moment";
|
||||
|
||||
/**
|
||||
* Asynchronously iterates over a collection and executes a callback function for each item.
|
||||
*
|
||||
|
@ -69,6 +67,7 @@ export function randomNum(min = 0, max = 100) {
|
|||
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a date for the specified client and locale.
|
||||
*
|
||||
|
@ -79,24 +78,9 @@ export function randomNum(min = 0, max = 100) {
|
|||
* @returns {string} The formatted date.
|
||||
*/
|
||||
export function printDate(client, date, format = null, locale = client.defaultLanguage.name) {
|
||||
const languageData = client.languages.find(language => language.name === locale);
|
||||
if (format === "" || format === null) format = languageData.defaultMomentFormat;
|
||||
return moment(new Date(date)).locale(languageData.moment).format(format);
|
||||
}
|
||||
/**
|
||||
* Formats a time value relative to the current time.
|
||||
*
|
||||
* @param {Object} client - The client object containing language data.
|
||||
* @param {string|number|Date} time - The time value to format.
|
||||
* @param {boolean} [type=false] - If true, formats the time as "X time ago", otherwise formats it as "in X time".
|
||||
* @param {boolean} [prefix=true] - If true, includes a prefix like "in" or "ago" in the formatted time.
|
||||
* @param {string} [locale=client.defaultLanguage.name] - The locale to use for formatting the time.
|
||||
* @returns {string} The formatted time value.
|
||||
*/
|
||||
export function convertTime(client, time, type = false, prefix = true, locale = client.defaultLanguage.name) {
|
||||
const languageData = client.languages.find(language => language.name === locale);
|
||||
const m = moment(time).locale(languageData.moment);
|
||||
return type ? m.toNow(!prefix) : m.fromNow(!prefix);
|
||||
const { format: languageFormat, locale: localeFormat } = client.languages.find(language => language.name === locale);
|
||||
if (format === "" || format === null) format = languageFormat;
|
||||
return new Intl.DateTimeFormat(localeFormat).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue