const Discord = require('discord.js');
const glob = require('glob');
const path = require('path');

class Bot {
    constructor() {
        this.client = new Discord.Client();
        this.token = 'MzAzMzI4NjQzNTUwMDE5NTg2.C9Wgwg.2SjC-LzYWuLNGPdhG0F0axdAqtM';
        this.commands = {};
        this.cmdCount = 0;

        this.loadCommands();

        this.client.on('ready', () => {
            console.log('Thonking.');
        });
    }

    thonk() {
        this.client.login(this.token)
    }

    loadCommands() {
        console.log('Loading commands...');

        glob.sync(path.join(__dirname, 'commands/*.js')).forEach( file => {
            this.addCommand(require(path.resolve(file)));
            this.cmdCount++
        });

        console.log(this.commands);

        console.log(`Finished loading ${this.cmdCount} commands.`)
    }

    addCommand(command) {
        this.commands[command.command] = {
            description: command.description,
            execute: command.execute
        }
    }


    //client.on('message', message => {
    //    message.react(':thonking:291056594601377792')
    //});
}

module.exports = Bot;
@@ -487,16 +487,113 @@
 s.token)
+;%0A%0A        this.client.on('message', message =%3E %7B%0A            this.runCommand(message)%0A        %7D)
 %0A    %7D%0A%0A
@@ -1113,16 +1113,586 @@
 %0A    %7D%0A%0A
+    runCommand(message) %7B%0A        const prefix = '!';%0A        const content = message.content;%0A%0A        if(content.startsWith(prefix)) %7B%0A            const formattedContent = content.slice(prefix.length, content.length);%0A            const command = formattedContent.split(' ')%5B0%5D;%0A%0A            if(this.commands.hasOwnProperty(command)) %7B%0A                console.log(this.commands%5Bcommand%5D.description);%0A            %7D else %7B%0A                message.channel.sendMessage('Command not recognized. Try !help for a list of available commands.');%0A            %7D%0A        %7D%0A    %7D%0A%0A
 %0A    //c

Add basic function to execute commands