We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const Discord = require('discord.js'); const client = new Discord.Client(); const db = require('quick.db'); const dotenv = require('dotenv'); dotenv.config(); const PREFIX = '!'; client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('message', async msg => { if (msg.author.bot) return; if (!msg.guild) return; if (!msg.content.startsWith(PREFIX)) return; const args = msg.content.slice(PREFIX.length).trim().split(/ +/); const command = args.shift().toLowerCase(); switch (command) { case 'daily': const lastDaily = await db.get(`lastDaily_${msg.author.id}`); const coins = await db.get(`coins_${msg.author.id}`); const now = Date.now(); const diff = now - lastDaily; const day = 24 * 60 * 60 * 1000; if (lastDaily !== null && diff < day) { const remainingTime = day - diff; const remainingTimeStr = formatTime(remainingTime); msg.reply(`Você precisa esperar ${remainingTimeStr} para receber suas moedas diárias novamente!`); } else { await db.set(`lastDaily_${msg.author.id}`, now); if (coins === null) { await db.set(`coins_${msg.author.id}`, 100); msg.reply('Você recebeu 100 moedas diárias!'); } else { await db.add(`coins_${msg.author.id}`, 100); msg.reply('Você recebeu 100 moedas diárias!'); } } break; case 'saldo': const balance = await db.get(`coins_${msg.author.id}`); msg.reply(`Seu saldo de moedas é de ${balance || 0} moedas!`); break; case 'comprar': const item = args[0]; const preco = 500; const coins = await db.get(`coins_${msg.author.id}`); if (coins < preco) { msg.reply(`Você não tem saldo suficiente para comprar o item ${item}!`); return; } await db.subtract(`coins_${msg.author.id}`, preco); msg.reply(`Você comprou o item ${item} por ${preco} moedas!`); break; default: break; } }); function formatTime(time) { const hours = Math.floor(time / (60 * 60 * 1000)); const minutes = Math.floor((time % (60 * 60 * 1000)) / (60 * 1000)); const seconds = Math.floor((time % (60 * 1000)) / 1000); return `${hours} horas, ${minutes} minutos e ${seconds} segundos`; } client.login(process.env.DISCORD_TOKEN);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: