Closed Shaylin-8bit closed 3 years ago
Rather than having nested if
blocks, it's probably best to just change the message listener in app.js
to something like this:
client.on('message', (msg) => {
if (message.channel.type === "dm") {
return;
}
if (msg.content.substring(0, 3) === 'cc!' && !(msg.member === client)) {
commandParser(msg);
}
});
We could also put a response in before the return
if we want.
Another example of how we might address this: https://discordjs.guide/command-handling/adding-features.html#guild-only-commands
It's fairly similar to what's discussed above.
Describe the bug
In the event a user DMs the bot with a command that has some form of the
isHighRoller()
function. This is due to the fact that since the user is not considered part of a server at the timemsg.members.role
is equal tonull
.To Reproduce
Steps to reproduce the behavior:
null
variables.Additional context
The bug is fixable by having the condition `if (!(msg.guild === null)) checked before the bot attempts to run commands.