fix dupe bug oops!

This commit is contained in:
Jill 2023-11-15 23:09:43 +03:00
parent 9658dd81ee
commit 9eecec4894
Signed by: oat
GPG Key ID: 33489AA58A955108
1 changed files with 13 additions and 13 deletions

View File

@ -323,6 +323,19 @@ function changeCounterInteractionBuilder(linked: boolean) {
return interaction.followUp(`You cannot **${amount > 0 ? (linked ? 'put' : 'produce') : (linked ? 'take' : 'consume')}** ${counter.emoji}.`);
}
const min = await getCounterConfig(counter.id, 'min') as number;
const max = await getCounterConfig(counter.id, 'max') as number;
if (counter.value + amount < min) {
if (min === 0) {
return interaction.followUp(`You cannot remove more than how much is in the counter (${counter.value}x ${counter.emoji})!`);
} else {
return interaction.followUp(`You cannot decrement past the minimum value (${min})!`);
}
}
if (counter.value + amount > max) {
return interaction.followUp(`You are adding more than the counter can hold (${max}x)!`);
}
let item;
let newInv;
if (linked) {
@ -346,19 +359,6 @@ function changeCounterInteractionBuilder(linked: boolean) {
newInv = await giveItem(member.id, item, amtInv);
}
const min = await getCounterConfig(counter.id, 'min') as number;
const max = await getCounterConfig(counter.id, 'max') as number;
if (counter.value + amount < min) {
if (min === 0) {
return interaction.followUp(`You cannot remove more than how much is in the counter (${counter.value}x ${counter.emoji})!`);
} else {
return interaction.followUp(`You cannot decrement past the minimum value (${min})!`);
}
}
if (counter.value + amount > max) {
return interaction.followUp(`You are adding more than the counter can hold (${max}x)!`);
}
const newCount = await changeCounter(counter.id, amount);
await updateCounter(interaction.client, counter, newCount);
await announceCounterUpdate(interaction.client, member, amount, counter, newCount, linked);