const prefix = require('./models/prefix') client.prefix = async function(message) { let custom; const data = await prefixSchema.findOne({ Guild : message.guild.id }) .catch(err => console.log(err)) if(data) { custom = data.Prefix; } else { custom = prefix; } return custom; } client.on('message', async (message) => { if (message.author.bot) return; const data = await prefix.findOne({ GuildID: message.guild.id }); const messageArray = message.content.split(' '); const cmd = messageArray[0]; const args = messageArray.slice(1); if(data) { const prefix = data.Prefix; if(message.mentions.users.first()) { const pingchannel = client.channels.cache.get('959866612675137576') if(message.mentions.users.first().id === '940712848349335612') return message.channel.send(`My prefix is **\`${prefix}\`**`), pingchannel.send(`${message.author.tag} pinged me`) } if (!message.content.startsWith(prefix)) return; const commandfile = client.commands.get(cmd.slice(prefix.length)) if(!commandfile){ //if (commandfile) { if(commandfile.timeout) { if(Timeout.has(`${commandfile.name}${message.author.id}`)) return message.channel.send(`You are on a \`${ms(Timeout.get(`${commandfile.name}${message.author.id}`) - Date.now(), {long : true})}\` cooldown.`) //commandfile.run(client, message, args) Timeout.set(`${commandfile.name}${message.author.id}`, Date.now() + commandfile.timeout) setTimeout(() => { Timeout.delete(`${commandfile.name}${message.author.id}`) }, commandfile.timeout) } //} } commandfile.run(client, message, args).catch(console.error) const lchannel = client.channels.cache.get('959866612675137576') lchannel.send(`${message.author.tag} used ${commandfile.name} command`) } else if (!data) { const prefix = "!!"; if(message.mentions.users.first()) { const pingchannel = client.channels.cache.get('959866612675137576') if(message.mentions.users.first().id === '940712848349335612') return message.channel.send(`My prefix is **\`!!\`**`), pingchannel.send(`${message.author.tag} pinged me`) } if (!message.content.startsWith(prefix)) return; const commandfile = client.commands.get(cmd.slice(prefix.length)) if(!commandfile){ if (commandfile) { if(commandfile.timeout) { if(Timeout.has(`${commandfile.name}${message.author.id}`)) return message.channel.send(`You are on a \`${ms(Timeout.get(`${commandfile.name}${message.author.id}`) - Date.now(), {long : true})}\` cooldown.`) commandfile.run(client, message, args).catch(console.error) Timeout.set(`${commandfile.name}${message.author.id}`, Date.now() + commandfile.timeout) setTimeout(() => { Timeout.delete(`${commandfile.name}${message.author.id}`) }, commandfile.timeout) } } } commandfile.run(client, message, args).catch(console.error) const lchannel = client.channels.cache.get('959866612675137576') lchannel.send(`${message.author.tag} used ${commandfile.name} command`) } })
if(!commandfile){ //if (commandfile) { if(commandfile.timeout) {
commandfile
commandfile.timeout
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)