mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 23:36:29 +02:00
Add box
This commit is contained in:
+30
-1
@@ -13,7 +13,7 @@ module.exports = {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('🛍️ Shop')
|
||||
.setThumbnail(message.guild.iconURL())
|
||||
.setDescription(`Sélectionnez un item à acheter. Voici les items disponibles :\n\n> 🔒 AntiRob - Protège contre les vols pendant 2 heures - Prix : 2000 coins`)
|
||||
.setDescription(`Sélectionnez un item à acheter. Voici les items disponibles :\n\n> 🔒 AntiRob - Protège contre les vols pendant 2 heures - Prix : 2000coins\n\n> 🗝️ Clef - Permet d'ouvrir une boite 100%gagante - Prix : 2500coins`)
|
||||
.setColor(await embedColor(message.author.id, message.guild.id))
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
|
||||
@@ -28,6 +28,12 @@ module.exports = {
|
||||
.setDescription('Protège contre les vols pendant 2 heures')
|
||||
.setEmoji('🔒')
|
||||
.setDefault(false),
|
||||
new StringSelectMenuOptionBuilder()
|
||||
.setLabel('🗝️ Clef')
|
||||
.setValue('key')
|
||||
.setDescription('Permet d\'ouvrir une boite - coûte 2500coins')
|
||||
.setEmoji('🗝️')
|
||||
.setDefault(false),
|
||||
);
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
@@ -64,6 +70,29 @@ module.exports = {
|
||||
|
||||
interaction.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
|
||||
}
|
||||
if (selected === 'key') {
|
||||
const user = await new Promise((resolve, reject) => {
|
||||
db.get(`SELECT * FROM users WHERE guildId = ? AND userId = ?`, [message.guild.id, message.author.id], (err, row) => {
|
||||
if (err) reject(err);
|
||||
resolve(row);
|
||||
});
|
||||
});
|
||||
|
||||
if (user.pocket < 2500) {
|
||||
return interaction.reply({ content: 'Vous n\'avez pas assez d\'argent pour acheter cet item.', ephemeral: true });
|
||||
}
|
||||
|
||||
db.run(`UPDATE users SET pocket = pocket - 2500, key = key + 1 WHERE guildId = ? AND userId = ?`, [message.guild.id, message.author.id]);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('🛍️ Shop')
|
||||
.setDescription(`Vous avez acheté l'item 🗝️ clef pour 2500 coins !`)
|
||||
.setColor(await embedColor(message.author.id, message.guild.id))
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
|
||||
|
||||
interaction.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,96 @@
|
||||
const { EmbedBuilder, ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js');
|
||||
const embedColor = require('../../fonctions/embedColor.js');
|
||||
const db = require('../../fonctions/database.js');
|
||||
|
||||
module.exports = {
|
||||
aliases: ['roulette'],
|
||||
description: 'Lance une roulette 100% gagante. (coûte une clef)',
|
||||
emote: '🎲',
|
||||
utilisation: '',
|
||||
permission: 0,
|
||||
|
||||
async execute(message, args, client) {
|
||||
const key = await new Promise((resolve, reject) => {
|
||||
db.get(`SELECT key FROM users WHERE userId = ? AND guildId = ?`, [message.author.id, message.guild.id], (err, row) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(row.key);
|
||||
}
|
||||
});
|
||||
});
|
||||
db.run(`UPDATE users SET key = key - 1 WHERE userId = ? AND guildId = ?`, [message.author.id, message.guild.id])
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('🗝️ Box')
|
||||
.setDescription(`🪙👑🗝️\n💰🔺🪙\n🪙🪙🗝️`)
|
||||
.setColor(await embedColor(message.author.id, message.guild.id))
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Demandé par ${message.author.tag} | Il te reste ${key - 1}clef`, iconURL: message.author.displayAvatarURL() })
|
||||
|
||||
const msg = await message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } })
|
||||
|
||||
const result = Math.floor(Math.random() * 30);
|
||||
let gain = '';
|
||||
let emoji = '';
|
||||
let recompense = '';
|
||||
if (result === 0) {
|
||||
gain = '30000';
|
||||
emoji = '💰';
|
||||
recompense = 'bank';
|
||||
} else if (result === 1) {
|
||||
gain = '5';
|
||||
emoji = '🗝️';
|
||||
recompense = 'key';
|
||||
} else if (result === 2) {
|
||||
emoji = '👑';
|
||||
recompense = 'couronne';
|
||||
} else if (result % 2 === 0) {
|
||||
gain = '5000';
|
||||
emoji = '🪙';
|
||||
recompense = 'pocket';
|
||||
} else {
|
||||
gain = '3';
|
||||
emoji = '🔺';
|
||||
recompense = 'reputation';
|
||||
}
|
||||
|
||||
if (recompense !== 'couronne') {
|
||||
await new Promise((resolve, reject) => {
|
||||
db.run(`UPDATE users SET ${recompense} = ${recompense} + ? WHERE userId = ? AND guildId = ?`, [gain, message.author.id, message.guild.id], (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
msg.delete()
|
||||
message.reply({ embeds: [
|
||||
new EmbedBuilder()
|
||||
.setTitle('🗝️ Box')
|
||||
.setDescription(`${emoji, emoji, emoji}\n${emoji, emoji, emoji}\n${emoji, emoji, emoji}\n\nVous avez gagner ${gain}${recompense} !`)
|
||||
.setColor(await embedColor(message.author.id, message.guild.id))
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Demandé par ${message.author.tag} | Il te reste ${key - 1}clef`, iconURL: message.author.displayAvatarURL() })
|
||||
], allowedMentions: { repliedUser: false } })
|
||||
} else {
|
||||
db.run(`UPDATE users SET bank = bank + ? WHERE userId = ? AND guildId = ?`, [15000, message.author.id, message.guild.id])
|
||||
db.run(`UPDATE users SET pocket = pocket + ? WHERE userId = ? AND guildId = ?`, [5000, message.author.id, message.guild.id])
|
||||
db.run(`UPDATE users SET reputation = reputation + ? WHERE userId = ? AND guildId = ?`, [5, message.author.id, message.guild.id])
|
||||
db.run(`UPDATE users SET key = key + ? WHERE userId = ? AND guildId = ?`, [5, message.author.id, message.guild.id])
|
||||
db.run(`UPDATE users SET xp = xp + ? WHERE userId = ? AND guildId = ?`, [50, message.author.id, message.guild.id])
|
||||
db.run(`UPDATE users SET lvl = lvl + ? WHERE userId = ? AND guildId = ?`, [2, message.author.id, message.guild.id])
|
||||
|
||||
msg.delete()
|
||||
message.reply({ embeds: [
|
||||
new EmbedBuilder()
|
||||
.setTitle('🗝️ Box')
|
||||
.setDescription(`${emoji, emoji, emoji}\n${emoji, emoji, emoji}\n${emoji, emoji, emoji}\n\n## **Vous avez gagner \`15000\`coins en bank, \`5000\`coins en poche, \`5\`reputation, \`5\`clef, \`50\`xp et \`5\`niveau !!**`)
|
||||
.setColor(await embedColor(message.author.id, message.guild.id))
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Demandé par ${message.author.tag} | Il te reste ${key - 1}clef`, iconURL: message.author.displayAvatarURL() })
|
||||
], allowedMentions: { repliedUser: false } })
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -20,6 +20,7 @@ db.run(`CREATE TABLE IF NOT EXISTS users (
|
||||
lvl INTERGER DEFAULT 0,
|
||||
xp INTERGER DEFAULT 0,
|
||||
objet INTERGER DEFAULT 0,
|
||||
key INTERGER DEFAULT 0,
|
||||
buyer BOOLEAN DEFAULT FALSE,
|
||||
owner BOOLEAN DEFAULT FALSE,
|
||||
whitelist BOOLEAN DEFAULT FALSE,
|
||||
|
||||
Reference in New Issue
Block a user