Did lots of unfinished stuff

This commit is contained in:
Emily 2020-03-31 19:24:51 +11:00
parent 10a0a7aca7
commit 2b6ac43e9b
4 changed files with 35 additions and 5 deletions

View File

@ -1,10 +1,7 @@
const Discord = require('discord.js')
const cooldown = new Discord.Collection()
module.exports = async (client, message) => {
if (message.author.bot) return
var prefix = '~'
var prefix = '!'
const myMention = `<@&${client.user.id}>`
const myMention2 = `<@!${client.user.id}>`
@ -37,6 +34,14 @@ module.exports = async (client, message) => {
return message.channel.send('You don\'t have permission to run this command!')
}
const delay = () => {
setTimeout(() => {
client.cooldown.get(cmd).delete(message.author.id);
message.channel.send(`${message.member} cooldown has expired for ${command} command.`)
}, commands.get(command) * 1000);
}
message.author.permLevel = level
message.flags = []

View File

@ -1,3 +1,4 @@
module.exports = (client) => {
client.logger.ready('Connected to Discord as ' + client.user.tag)
client.logger.debug(client.cooldown)
}

View File

@ -17,7 +17,11 @@ require('./modules/functions')(client)
client.logger = require('tracer').colorConsole({
format: [
'{{timestamp}} <{{title}}> ({{file}}) {{message}}'
'{{timestamp}} <{{title}}> {{message}}',
{
error: '{{timestamp}} <{{title}}> ({{file}}) {{message}}',
fatal: '{{timestamp}} <{{title}}> ({{file}}) {{message}}'
}
],
dateformat: 'dd-mm-yyyy HH:MM:ss',
methods: ['log', 'debug', 'info', 'ready', 'warn', 'error', 'fatal'],
@ -47,6 +51,7 @@ client.config = require('./config')
// Command/alias cache
client.commands = new Discord.Collection()
client.cooldown = new Discord.Collection()
client.aliases = new Discord.Collection()
// Initialization function

View File

@ -1,4 +1,21 @@
module.exports = client => {
client.permlevel = message => {
let permlvl = 0
const permOrder = client.config.permLevels.slice(0).sort((p, c) => p.level < c.level ? 1 : -1)
while (permOrder.length) {
const currentLevel = permOrder.shift()
if (message.guild && currentLevel.guildOnly) continue
if (currentLevel.check(message)) {
permlvl = currentLevel.level
break
}
}
return permlvl
}
client.loadCommand = (commandName) => {
try {
const props = require(`../commands/${commandName}`)
@ -6,6 +23,8 @@ module.exports = client => {
props.init(client)
}
client.commands.set(props.help.name, props)
// So commands can each have their own cooldown time
client.cooldown.set(props.help.name, new Map())
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name)
})