Explorar o código

Fix crashing on some auth checks

denikson %!s(int64=6) %!d(string=hai) anos
pai
achega
18b66bb065
Modificáronse 3 ficheiros con 4 adicións e 4 borrados
  1. 1 1
      commands/help.js
  2. 2 2
      commands/quote.js
  3. 1 1
      util.js

+ 1 - 1
commands/help.js

@@ -2,7 +2,7 @@ const util = require("../util.js");
 
 const commands = {
     "help": msg => {
-        let isAuthed = util.isAuthorised(msg.author);
+        let isAuthed = util.isAuthorised(msg.member);
 
         let baseCommands = "\n";
         let modCommands = "\n";

+ 2 - 2
commands/quote.js

@@ -31,7 +31,7 @@ function minify(str, maxLength) {
 
 const commands = {
     "add quote": (msg, c) => {
-        if (!util.isAuthorised(msg.author))
+        if (!util.isAuthorised(msg.member))
             return;
 
         let result = quotePattern.exec(c);
@@ -68,7 +68,7 @@ const commands = {
         msg.channel.send(`${msg.author.toString()} Removed quote #${val}!`);
     },
     "quotes": msg => {
-        if (!util.isAuthorised(msg.author)) {
+        if (!util.isAuthorised(msg.member)) {
             msg.channel.send(`${msg.author.toString()} To prevent spamming, only bot moderators can view all quotes!`);
             return;
         }

+ 1 - 1
util.js

@@ -21,7 +21,7 @@ function isValidImage(fileName) {
 function isAuthorised(member) {
     if (db.get("editors.users").includes(member.id).value())
         return true;
-    if (member.roles.size == 0 || db.get("editors.roles").intersectionWith(member.roles.keyArray()).isEmpty().value())
+    if (db.get("editors.roles").intersectionWith(member.roles.keyArray()).isEmpty().value())
         return false;
     return true;
 }