mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 23:36:29 +02:00
Add recolt
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const db = require('../../fonctions/database.js');
|
||||
const embedColor = require('../../fonctions/embedColor.js');
|
||||
|
||||
module.exports = {
|
||||
aliases: ['recolt', 'recolte'],
|
||||
description: 'Recolter des objets que vous pourrez vendre ensuite.',
|
||||
emote: '💼',
|
||||
utilisation: '',
|
||||
permission: 0,
|
||||
|
||||
async execute(message, args, client) {
|
||||
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);
|
||||
});
|
||||
});
|
||||
const lastRecolt = user.lastRecolt
|
||||
const objet = user.objet
|
||||
|
||||
if (lastRecolt > Date.now() - 2700000) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Recolte Impossible')
|
||||
.setDescription(`❌ La météo annonce une tempete... Veuillez attendre \`${Math.floor((lastRecolt + 2700000 - Date.now()) / 60000)}\` minutes avant de pouvoir recolter.`)
|
||||
.setColor(await embedColor(message.author.id, message.guild.id))
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
|
||||
|
||||
return message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
|
||||
}
|
||||
|
||||
const randomAmount = Math.floor(Math.random() * 2) + 1;
|
||||
db.run(`UPDATE users SET objet = ?, lastRecolt = ? WHERE guildId = ? AND userId = ?`, [objet + randomAmount, Date.now(), message.guild.id, message.author.id]);
|
||||
|
||||
const recolts = [
|
||||
`🍒 Vous avez recolté des cerises sur ${randomAmount} arbre(s) dans votre jardin.`,
|
||||
`🌽 Vous avez recolté ${randomAmount} parcelle(s) de maïs et vous avez tout mis à l'abri.`,
|
||||
`🌳 Vous avez trouvé de quoi vous chauffer en vous promenant en foret, vous rentrer chez vous avec ${randomAmount} grosse(s) bûche(s) de bois.`
|
||||
];
|
||||
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Objet recolter')
|
||||
.setDescription(recolts[Math.floor(Math.random() * recolts.length)])
|
||||
.setColor(await embedColor(message.author.id, message.guild.id))
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
|
||||
|
||||
message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
|
||||
},
|
||||
};
|
||||
@@ -17,12 +17,14 @@ db.run(`CREATE TABLE IF NOT EXISTS users (
|
||||
reputation INTEGER DEFAULT 0,
|
||||
lvl INTERGER DEFAULT 0,
|
||||
xp INTERGER DEFAULT 0,
|
||||
objet INTERGER DEFAULT 0,
|
||||
buyer BOOLEAN DEFAULT FALSE,
|
||||
owner BOOLEAN DEFAULT FALSE,
|
||||
whitelist BOOLEAN DEFAULT FALSE,
|
||||
blacklist BOOLEAN DEFAULT FALSE,
|
||||
antiRob INTEGER DEFAULT 0,
|
||||
lastRob INTEGER DEFAULT 0,
|
||||
lastRecolt INTEGER DEFAULT 0,
|
||||
lastWork INTEGER DEFAULT 0,
|
||||
lastDaily INTEGER DEFAULT 0,
|
||||
lastRep INTERGER DEFAULT 0,
|
||||
|
||||
Reference in New Issue
Block a user