/*
 * Copyright 2018 John Grosh (john.a.grosh@gmail.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jagrosh.vortex.commands.general;

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.commons.JDAUtilitiesInfo;
import com.jagrosh.vortex.Constants;
import com.jagrosh.vortex.utils.FormatUtil;
import java.awt.Color;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDAInfo;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.sharding.ShardManager;
import net.dv8tion.jda.api.entities.User;

/**
 *
 * @author John Grosh (john.a.grosh@gmail.com)
 */
public class TouchCmd extends Command
{
    public TouchCmd()
    {
        this.name = "touch";
        this.help = "touch a user";
        this.guildOnly = false;
        this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS};
    }

    @Override
    protected void execute(CommandEvent event)
    {
        if (event.getArgs().isEmpty()) {
            event.replyError("Please mention a user to touch!");
            return;
        }

        // Try to resolve a user from args
        User target = event.getMessage().getMentionedUsers().stream().findFirst().orElse(null);
        if (target == null) {
            event.replyError("Could not find a mentioned user!");
            return;
        }

        // Build the response
        event.reply(new MessageBuilder()
                .setContent(target.getAsMention() + "has been touched. mmmmm, :yum:")
                // .setEmbed(new EmbedBuilder()
                //         .setColor(!event.isFromType(ChannelType.TEXT) ? Color.GRAY : event.getSelfMember().getColor())
                //         .setDescription(target.getAsMention() + " has been touching. mmmmmm :yummy:")
                //         .build())
                .build());
    }
}
