Create use effect command #419

Open
Vylpes wants to merge 26 commits from feature/380-use-effect into develop
3 changed files with 4 additions and 8 deletions
Showing only changes of commit 90bda9d9df - Show all commits

View file

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

View file

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

View file

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