Skip to content

Commit 2ffaa0f

Browse files
committed
Finish conversion of moment to luxon
1 parent b856483 commit 2ffaa0f

File tree

12 files changed

+103
-61
lines changed

12 files changed

+103
-61
lines changed

commands/Economy/crime.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,18 @@ class Crime extends Command {
5454
if (expiresAt) {
5555
const timeleft = new Date(expiresAt) - Date.now();
5656
if (timeleft > 0 && timeleft <= cooldown * 1000) {
57-
const timeLeft = Duration.fromMillis(timeleft)
58-
.shiftTo('years', 'months', 'days', 'hours', 'minutes', 'seconds')
59-
.toHuman({ showZeros: false });
60-
61-
embed.setDescription(`Please wait ${timeLeft} to commit a crime again.`);
57+
const timeLeftDuration = Duration.fromMillis(timeleft).shiftTo(
58+
'years',
59+
'months',
60+
'days',
61+
'hours',
62+
'minutes',
63+
'seconds',
64+
);
65+
const roundedTimeLeftDuration = timeLeftDuration.set({ seconds: Math.floor(timeLeftDuration.seconds) });
66+
const tLeft = roundedTimeLeftDuration.toHuman({ showZeros: false });
67+
68+
embed.setDescription(`Please wait ${tLeft} to commit a crime again.`);
6269

6370
return msg.channel.send({ embeds: [embed] });
6471
}

commands/Economy/rob.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Command = require('../../base/Command.js');
22
const { EmbedBuilder } = require('discord.js');
33
const { QuickDB } = require('quick.db');
4-
const moment = require('moment');
4+
const { Duration } = require('luxon');
55
const db = new QuickDB();
66

77
class Rob extends Command {
@@ -55,9 +55,16 @@ class Rob extends Command {
5555
if (expiresAt) {
5656
const timeleft = new Date(expiresAt) - Date.now();
5757
if (timeleft > 0 && timeleft <= cooldown * 1000) {
58-
const tLeft = moment
59-
.duration(timeleft)
60-
.format('y[ years][,] M[ Months][,] d[ days][,] h[ hours][,] m[ minutes][ and] s[ seconds]'); // format to any format
58+
const timeLeftDuration = Duration.fromMillis(timeleft).shiftTo(
59+
'years',
60+
'months',
61+
'days',
62+
'hours',
63+
'minutes',
64+
'seconds',
65+
);
66+
const roundedTimeLeftDuration = timeLeftDuration.set({ seconds: Math.floor(timeLeftDuration.seconds) });
67+
const tLeft = roundedTimeLeftDuration.toHuman({ showZeros: false });
6168

6269
embed.setDescription(`Please wait ${tLeft} before robbing someone again.`);
6370

commands/Economy/slut.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,16 @@ class Slut extends Command {
5656
if (expiresAt) {
5757
const timeleft = new Date(expiresAt) - Date.now();
5858
if (timeleft > 0 && timeleft <= cooldown * 1000) {
59-
const tLeft = Duration.fromMillis(timeleft)
60-
.shiftTo('years', 'months', 'days', 'hours', 'minutes', 'seconds')
61-
.toHuman({ showZeros: false });
59+
const timeLeftDuration = Duration.fromMillis(timeleft).shiftTo(
60+
'years',
61+
'months',
62+
'days',
63+
'hours',
64+
'minutes',
65+
'seconds',
66+
);
67+
const roundedTimeLeftDuration = timeLeftDuration.set({ seconds: Math.floor(timeLeftDuration.seconds) });
68+
const tLeft = roundedTimeLeftDuration.toHuman({ showZeros: false });
6269

6370
embed.setDescription(`Please wait ${tLeft} to be a slut again.`);
6471

commands/Economy/work.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Command = require('../../base/Command.js');
22
const { EmbedBuilder } = require('discord.js');
33
const { QuickDB } = require('quick.db');
4-
const moment = require('moment');
4+
const { Duration } = require('luxon');
55
const db = new QuickDB();
66

77
class Work extends Command {
@@ -52,9 +52,17 @@ class Work extends Command {
5252
if (expiresAt) {
5353
const timeleft = new Date(expiresAt) - Date.now();
5454
if (timeleft > 0 && timeleft <= cooldown * 1000) {
55-
const tLeft = moment
56-
.duration(timeleft)
57-
.format('y[ years][,] M[ Months][,] d[ days][,] h[ hours][,] m[ minutes][ and] s[ seconds]');
55+
const timeLeftDuration = Duration.fromMillis(timeleft).shiftTo(
56+
'years',
57+
'months',
58+
'days',
59+
'hours',
60+
'minutes',
61+
'seconds',
62+
);
63+
const roundedTimeLeftDuration = timeLeftDuration.set({ seconds: Math.floor(timeLeftDuration.seconds) });
64+
const tLeft = roundedTimeLeftDuration.toHuman({ showZeros: false });
65+
5866
embed.setDescription(`Please wait ${tLeft} to work again.`);
5967

6068
return msg.channel.send({ embeds: [embed] });

commands/Search/github.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const Command = require('../../base/Command.js');
22
const { EmbedBuilder } = require('discord.js');
33
const fetch = require('node-superfetch');
4-
const moment = require('moment');
54

65
class Github extends Command {
76
constructor(client) {
@@ -44,6 +43,9 @@ class Github extends Command {
4443
.get(`https://api.github.com/repos/${author}/${repository}`)
4544
.set({ Authorization: `token ${this.client.config.github}` });
4645

46+
const createdAt = Math.floor(new Date(body.created_at).getTime() / 1000);
47+
const updatedAt = Math.floor(new Date(body.updated_at).getTime() / 1000);
48+
4749
const embed = new EmbedBuilder()
4850
.setColor(msg.settings.embedColor)
4951
.setAuthor({ name: 'GitHub', iconURL: 'https://i.imgur.com/e4HunUm.png', url: 'https://github.com/' })
@@ -59,8 +61,8 @@ class Github extends Command {
5961
{ name: 'License', value: body.license ? body.license.name : 'None', inline: true },
6062
{ name: 'Archived', value: body.archived ? 'Yes' : 'No', inline: true },
6163
{ name: 'Size', value: `${(body.size / 1000).toLocaleString()} MB`, inline: true },
62-
{ name: 'Creation Date', value: moment.utc(body.created_at).format('MM/DD/YYYY h:mm A'), inline: true },
63-
{ name: 'Modification Date', value: moment.utc(body.updated_at).format('MM/DD/YYYY h:mm A'), inline: true },
64+
{ name: 'Creation Date', value: `<t:${createdAt}:s>`, inline: true },
65+
{ name: 'Modification Date', value: `<t:${updatedAt}:s>`, inline: true },
6466
]);
6567

6668
return msg.channel.send({ embeds: [embed] });

package-lock.json

Lines changed: 2 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mythical",
3-
"version": "5.10.1",
3+
"version": "5.10.2",
44
"description": "Mythical Bot",
55
"owner": "themondon",
66
"main": "index.js",
@@ -49,7 +49,6 @@
4949
"lavalink-client": "^2.9.7",
5050
"luxon": "^3.1.1",
5151
"mathjs": "^13.0.3",
52-
"moment": "^2.29.4",
5352
"mysql2": "^3.19.0",
5453
"nearest-color": "^0.4.4",
5554
"nekos.life": "^3.0.0",

slash_commands/Economy/crime.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { EmbedBuilder, SlashCommandBuilder, InteractionContextType } = require('discord.js');
22
const { QuickDB } = require('quick.db');
3-
const moment = require('moment');
3+
const { Duration } = require('luxon');
44
const db = new QuickDB();
55

66
exports.conf = {
@@ -52,10 +52,18 @@ exports.run = async (interaction) => {
5252
if (expiresAt) {
5353
const timeleft = new Date(expiresAt) - Date.now();
5454
if (timeleft > 0 && timeleft <= cooldown * 1000) {
55-
const timeLeft = moment
56-
.duration(timeleft)
57-
.format('y[ years][,] M[ Months][,] d[ days][,] h[ hours][,] m[ minutes][ and] s[ seconds]'); // format to any format
58-
embed.setDescription(`Please wait ${timeLeft} to commit a crime again.`);
55+
const timeLeftDuration = Duration.fromMillis(timeleft).shiftTo(
56+
'years',
57+
'months',
58+
'days',
59+
'hours',
60+
'minutes',
61+
'seconds',
62+
);
63+
const roundedTimeLeftDuration = timeLeftDuration.set({ seconds: Math.floor(timeLeftDuration.seconds) });
64+
const tLeft = roundedTimeLeftDuration.toHuman({ showZeros: false });
65+
66+
embed.setDescription(`Please wait ${tLeft} to commit a crime again.`);
5967

6068
return interaction.editReply({ embeds: [embed] });
6169
}

slash_commands/Economy/slut.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { EmbedBuilder, SlashCommandBuilder, InteractionContextType } = require('discord.js');
22
const { QuickDB } = require('quick.db');
3-
const moment = require('moment');
3+
const { Duration } = require('luxon');
44
const db = new QuickDB();
55

66
exports.conf = {
@@ -51,9 +51,17 @@ exports.run = async (interaction) => {
5151
if (expiresAt) {
5252
const timeleft = new Date(expiresAt) - Date.now();
5353
if (timeleft > 0 && timeleft <= cooldown * 1000) {
54-
const tLeft = moment
55-
.duration(timeleft)
56-
.format('y[ years][,] M[ Months][,] d[ days][,] h[ hours][,] m[ minutes][ and] s[ seconds]');
54+
const timeLeftDuration = Duration.fromMillis(timeleft).shiftTo(
55+
'years',
56+
'months',
57+
'days',
58+
'hours',
59+
'minutes',
60+
'seconds',
61+
);
62+
const roundedTimeLeftDuration = timeLeftDuration.set({ seconds: Math.floor(timeLeftDuration.seconds) });
63+
const tLeft = roundedTimeLeftDuration.toHuman({ showZeros: false });
64+
5765
embed.setDescription(`Please wait ${tLeft} to be a slut again.`);
5866

5967
return interaction.editReply({ embeds: [embed] });

slash_commands/Economy/work.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { EmbedBuilder, SlashCommandBuilder, InteractionContextType } = require('discord.js');
22
const { QuickDB } = require('quick.db');
3-
const moment = require('moment');
3+
const { Duration } = require('luxon');
44
const db = new QuickDB();
55

66
exports.conf = {
@@ -52,9 +52,17 @@ exports.run = async (interaction) => {
5252
if (expiresAt) {
5353
const timeleft = new Date(expiresAt) - Date.now();
5454
if (timeleft > 0 && timeleft <= cooldown * 1000) {
55-
const tLeft = moment
56-
.duration(timeleft)
57-
.format('y[ years][,] M[ Months][,] d[ days][,] h[ hours][,] m[ minutes][ and] s[ seconds]');
55+
const timeLeftDuration = Duration.fromMillis(timeleft).shiftTo(
56+
'years',
57+
'months',
58+
'days',
59+
'hours',
60+
'minutes',
61+
'seconds',
62+
);
63+
const roundedTimeLeftDuration = timeLeftDuration.set({ seconds: Math.floor(timeLeftDuration.seconds) });
64+
const tLeft = roundedTimeLeftDuration.toHuman({ showZeros: false });
65+
5866
embed.setDescription(`Please wait ${tLeft} to work again.`);
5967

6068
return interaction.editReply({ embeds: [embed] });

0 commit comments

Comments
 (0)