fixing prefix cmdhandler

This commit is contained in:
Marcus Netz
2020-11-23 14:52:42 +01:00
parent 057859a820
commit 4918789a52

View File

@ -11,7 +11,7 @@ const skill = require('./skill');
const createFromFile = require('./createFromFile'); const createFromFile = require('./createFromFile');
require('dotenv').config(); require('dotenv').config();
const prefix = process.env.PREFIX || '!'; const cmdprefix = process.env.CMDPREFIX || '!';
const commands = { const commands = {
roll, roll,
@ -30,8 +30,8 @@ const Datastore = require('nedb'),
}); });
module.exports = async (message) => { module.exports = async (message) => {
console.log(`${new Date().toUTCString} ${message.author.tag}`) console.log(`${new Date().toUTCString()} ${message.author.tag} (size: ${message.attachments.size})`)
if ((message.attachments.size > 0) && message.channel.type == 'dm') { if ((message.attachments.size > 0) && message.channel.type == 'dm' && !message.author.bot) {
try { try {
const response = await fetch(message.attachments.first().url); const response = await fetch(message.attachments.first().url);
const data = await validateJSON(response); const data = await validateJSON(response);
@ -43,8 +43,8 @@ module.exports = async (message) => {
} }
else { else {
if (!message.content.startsWith(prefix) || message.author.bot) return; if (!message.content.startsWith(cmdprefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(' '); const args = message.content.slice(cmdprefix.length).split(' ');
const command = args.shift().toLowerCase(); const command = args.shift().toLowerCase();
if (Object.keys(commands).includes(command)) { if (Object.keys(commands).includes(command)) {
commands[command](message, args, db); commands[command](message, args, db);