woomy/modules/functions.js

28 lines
766 B
JavaScript
Raw Normal View History

2020-03-29 07:45:09 +00:00
module.exports = client => {
2020-03-31 07:59:09 +00:00
client.loadCommand = (commandName) => {
try {
const props = require(`../commands/${commandName}`)
if (props.init) {
props.init(client)
}
client.commands.set(props.help.name, props)
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name)
})
return false
} catch (e) {
return `Failed to load ${commandName}: ${e}`
}
}
2020-03-29 07:45:09 +00:00
2020-03-31 07:59:09 +00:00
process.on('uncaughtException', (err) => {
const errorMsg = err.stack.replace(new RegExp(`${__dirname}/`, 'g'), './')
client.logger.fatal(`Uncaught Exception: ${errorMsg}`)
process.exit(1)
})
process.on('unhandledRejection', err => {
client.logger.error(`Unhandled rejection: ${err}`)
})
2020-03-29 07:45:09 +00:00
}