#include <ChatCommand/UnbanCommand/UnbanCommand.hpp>

UnbanCommand::UnbanCommand(ServerWorld &world)
{
    require(UserPermission::UnbanUsers);

    addVariant(
        "<username> - Unban a user.",
        [](Player &player, std::string userName)
        {
            std::string error = userDB.unbanUser(userName);
            if (error.size() != 0)
            {
                player.writeChat(formatString("Cannot unban '$+': $+", userName, error), Color::error);
                return;
            };

            player.writeChat(formatString("Player '$+' has been unbanned.", userName), Color::success);
        }
    );
}