#include <ChatCommand/ApproveCommand/ApproveCommand.hpp>
#include <UserPermission/UserPermission.hpp>

ApproveCommand::ApproveCommand()
{
    require(UserPermission::ApproveNewUsers);

    addVariant(
        "<username> - Approve a user who requested registration.",
        [](Player &player, std::string userName)
        {
            if (userDB.approveUser(userName))
            {
                player.writeChat(formatString("User '$+' approved.", userName), Color::success);
                Log::info(formatString("User '$+' approved.", userName));
            }
            else
            {
                player.writeChat(formatString("User '$+' is not pending approval.", userName), Color::error);
                Log::error(formatString("User '$+' is not pending approval.", userName));
            }
        }
    );
}