Skip to content

Commit

Permalink
Added whitelist for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Farami committed May 4, 2016
1 parent 59dfe43 commit a832427
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/messageHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
const configFile = require('./config.json');
const inArray = require('in-array');
const whitelist = require('../whitelist.json');

module.exports = class MessageHandler {
constructor(client) {
Expand All @@ -14,18 +15,20 @@ module.exports = class MessageHandler {
}

handleMessage(message) {
console.log('handledMessage got called with: ' + message);

// dont answer my own messages
if (message.author === this.client.user) {
if (!message.content.startsWith(configFile.messagePrefix)) {
return;
}

if (message.author.username === 'Risenx') {
console.log('handleMessage got called with: ' + message);

// dont answer my own messages
if (message.author === this.client.user) {
return;
}

if (!message.content.startsWith(configFile.messagePrefix)) {
// ignore message from people that are not in whitelist
// TODO: Rewrite this as a proper rights system
if (!inArray(whitelist, message.author.username)) {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions whitelist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"Farami",
"slowChildPlaying"
]

0 comments on commit a832427

Please sign in to comment.