bug fix, substract points to user when he bet (i forgot the line)
This commit is contained in:
parent
49e52bf2dd
commit
d42b8e007f
@ -127,8 +127,8 @@ async function findBetValueForUser(userId, guildId) {
|
||||
|
||||
async function substractUserPoints(userId, betValue) {
|
||||
await DATABASE_CLIENT.query(
|
||||
"UPDATE member SET points = points - $1 WHERE user_id = $2 AND points - $1 >= 50",
|
||||
betValue, userId
|
||||
"UPDATE member SET points = GREATEST(points - $1, 50), bet_value=50 WHERE user_id = $2",
|
||||
[betValue, userId]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ const {
|
||||
addPointsToUser,
|
||||
closePoll,
|
||||
findUserPoints,
|
||||
changeNextBetValueForUser, isPollOpened
|
||||
changeNextBetValueForUser, isPollOpened, substractUserPoints
|
||||
} = require('./database');
|
||||
const {TOKEN} = require('../config.json');
|
||||
const {v4: uuidv4} = require('uuid');
|
||||
@ -218,7 +218,6 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||
} else if (interaction.isMessageComponent()) {
|
||||
sendAppropriateMessageToUserWhenHeVotes(interaction);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
async function sendAppropriateMessageToUserWhenHeVotes(interaction) {
|
||||
@ -240,10 +239,11 @@ async function sendAppropriateMessageToUserWhenHeVotes(interaction) {
|
||||
});
|
||||
} else {
|
||||
const userBetValue = await findBetValueForUser(interaction.user.id, interaction.guildId);
|
||||
await bet(interaction.user.id, interaction.customId.split("_")[0], interaction.guildId, interaction.customId, userBetValue)
|
||||
await bet(interaction.user.id, interaction.customId.split("_")[0], interaction.guildId, interaction.customId, userBetValue);
|
||||
await substractUserPoints(interaction.user.id, userBetValue);
|
||||
await interaction.reply({
|
||||
flags: MessageFlags.Ephemeral,
|
||||
content: `${interaction.user.username}, tu as misé ${userBetValue} sur l'option **${interaction.customId.split("_")[1]}** ! 🎉`
|
||||
content: `${interaction.user.username}, tu as misé ${userBetValue} sur l'option **${interaction.customId.split("_")[1]}** ! 🎉 (la valeur de ton prochain pari a été réinitialisée à 50)`
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user