From 9e5c9da6e2761cf5a18c01afbfb04ac666571cc0 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 27 Oct 2019 21:21:26 -0400 Subject: [PATCH] add checks for presence of user/role perms before checking --- src/events/messageCreate.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 93cb6a3..86d8625 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -16,12 +16,21 @@ export default class { const resolved: Command = this.client.util.resolveCommand(command); if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; - const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id); + let hasUserPerms: boolean; + if (resolved.permissions.users) { + hasUserPerms = resolved.permissions.users.includes(message.author.id); + } else { + hasUserPerms = true; + } let hasRolePerms: boolean = false; - for (const role of resolved.permissions.roles) { - if (message.member && message.member.roles.includes(role)) { - hasRolePerms = true; break; + if (resolved.permissions.roles) { + for (const role of resolved.permissions.roles) { + if (message.member && message.member.roles.includes(role)) { + hasRolePerms = true; break; + } } + } else { + hasRolePerms = true; } if (!hasRolePerms && !hasUserPerms) return; if (!resolved.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; }