Permalink
Browse files

Fix for the onCommandRun event

When a user runs a command from a direct message, there's no guild obviously. I currently require the guild id in order to track usage counts. 

This commit fixes that requirement by doing a null check on `msg.guild` before continuing on.
  • Loading branch information...
Alcha committed Oct 13, 2018
1 parent e9e3854 commit bf4745311e233aabde5ce2249cb361445dfed9f7
Showing with 6 additions and 4 deletions.
  1. +6 −4 Tron.js
10 Tron.js
@@ -68,10 +68,12 @@ client.on('ready', () => {
})

client.on('commandRun', (cmd, promise, msg) => {
console.log(`Running ${cmd.name} on server ${msg.guild.name} by ${msg.author.username}...`)
const command = new CommandHelper(msg, cmd)

command.updateUsage(cmd.name).catch(err => console.error(err))
if (msg.guild !== null) {
console.log(`Running ${cmd.name} on server ${msg.guild.name} by ${msg.author.username}...`)
const command = new CommandHelper(msg, cmd)

command.updateUsage(cmd.name).catch(err => console.error(err))
}
})

client.on('unknownCommand', msg => {

0 comments on commit bf47453

Please sign in to comment.