package me.lenajenichen.voicebot;

import me.lenajenichen.voicebot.commands.LockCommand;
import me.lenajenichen.voicebot.commands.ServerCommand;
import me.lenajenichen.voicebot.commands.SetupCommand;
import me.lenajenichen.voicebot.commands.UnlockCommand;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;

import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;

public class CommandManager {

    public ConcurrentHashMap<String, ServerCommand> commands;

    public CommandManager() {
        this.commands = new ConcurrentHashMap<>();

        this.commands.put("unlock", new UnlockCommand());
        this.commands.put("lock", new LockCommand());
        this.commands.put("setup", new SetupCommand());
    }

    public boolean perform(String command, Member m, TextChannel channel, Message message) {

        ServerCommand cmd;
        if((cmd = this.commands.get(command.toLowerCase())) != null) {
            cmd.performCommand(m, channel, message);
            return true;
        }

        return false;
    }

}
