Fix time not using proper unix time

This commit is contained in:
Ethan Lane 2024-12-27 18:22:04 +00:00
parent a3f307d87e
commit 90bda9d9df
3 changed files with 4 additions and 8 deletions

View file

@ -61,7 +61,8 @@ export default class Effects extends ButtonEvent {
}
const now = new Date();
const whenExpires = new Date(now.getMilliseconds() + effectDetail.duration);
const whenExpires = new Date(now.getTime() + effectDetail.duration);
const result = await EffectHelper.UseEffect(interaction.user.id, id, whenExpires);
@ -78,7 +79,7 @@ export default class Effects extends ButtonEvent {
},
{
name: "Expires",
value: `<t:${whenExpires.getMilliseconds()}:f>`,
value: `<t:${Math.round(whenExpires.getTime() / 1000)}:f>`,
inline: true,
},
]);

View file

@ -53,8 +53,6 @@ export default class Drop extends Command {
const hasChanceUpEffect = await EffectHelper.HasEffect(interaction.user.id, "unclaimed");
console.log(hasChanceUpEffect);
if (hasChanceUpEffect && Math.random() <= CardConstants.UnusedChanceUpChance) {
randomCard = await CardDropHelperMetadata.GetRandomCardUnclaimed(interaction.user.id);
} else {

View file

@ -37,19 +37,16 @@ export default class EffectHelper {
const now = new Date();
if (!effect || effect.Unused == 0) {
console.log(1);
return false;
}
const effectDetail = EffectDetails.get(effect.Name);
if (!effectDetail) {
console.log(2);
return false;
}
if (effect.WhenExpires && now < new Date(effect.WhenExpires.getMilliseconds() + effectDetail.cooldown)) {
console.log(3);
if (effect.WhenExpires && now < new Date(effect.WhenExpires.getTime() + effectDetail.cooldown)) {
return false;
}