const express = require("express") const app = express() const port = 3000 const Discord = require('discord.js') const fs = require('fs'); const { token, default_prefix } = require('./core/config.json'); const db = require("quick.db") const client = new Discord.Client var colors = require('colors'); client.commands = new Discord.Collection(); client.prefix = default_prefix; const cooldowns = new Discord.Collection(); const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); let cmdCounter = 0; for (const file of commandFiles) { const commandName = require(`./commands/${file}`); client.commands.set(commandName.name, commandName); cmdCounter++; console.log(`Successfully Loaded ${file}! (${cmdCounter}/${commandFiles.length})`); } console.log("Bot online!".green) client.once('ready', () => { const statuses = ["+help"] setInterval(function() { const status = statuses[Math.floor(Math.random() * statuses.length)]; client.user.setActivity({type: 'PLAYING', name: status}); }, 4000) }); client.on('message', message => { if (!message.guild) return; let prefix = db.get(`prefix_${message.guild.id}`); if (prefix === null) prefix = default_prefix; if (message.content.startsWith("guilds")) message.reply(`${client.guilds.cache.size} servers`) if (!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.length).split(/ +/); const commandName = args.shift().toLowerCase(); const command = (client.commands.get(commandName) || client.commands.find(c => c.aliases && c.aliases.includes(commandName))); if (!command) return; if (message.channel.type != 'text') return message.reply('This command cannot be used outside of a server!'); if (command.args && !args.length) { if (command.usage) { reply += `The correct usage for this command would be: \`${prefix}${command.name} ${command.usage}\`.`; return message.channel.send(reply); } } /*if (!cooldowns.has(command.name)) { cooldowns.set(command.name, new Discord.Collection()); } const now = Date.now(); const timestamps = cooldowns.get(command.name); const cooldownAmount = (command.cooldown || 0.1) * 60000; if (timestamps.has(message.author.id)) { if (timestamps.has(message.author.id)) { const expirationTime = timestamps.get(message.author.id) + cooldownAmount; if (now < expirationTime) { const timeLeft = (expirationTime - now) / 60000; let name = "minutes" if(61 < timeLeft) name = "hour(s)" if(1440 < timeLeft) name = "day(s)" let time = timeLeft.toFixed(1) if(timeLeft.toFixed(1) > 60) time = timeLeft.toFixed(1)/60 if(timeLeft.toFixed(1) > 1440) time = timeLeft.toFixed(1)/1440 let time1 = Math.round(time * 1) / 1 return message.reply(`Please wait ${time1} more ` + name +` before reusing the \`${command.name}\` command.`); } } } timestamps.set(message.author.id, now); setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);*/ }); client.on("message", async msg => { let prefix = db.get(`prefix_${msg.guild.id}`); if (prefix === null) prefix = default_prefix; if(msg.content == "!db") { return msg.reply(`${require("quick.db").version}`) } if (msg.mentions.has(`734537695698878565`)) { msg.channel.send(`Hi, ${msg.member.user}. here's my prefix for this server \`${prefix}\`. You can also do \`${prefix}help\` for more help!`) } }) client.login(process.env.token)