/*
* 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 BombCmd extends Command
{
public BombCmd()
{
this.name = "bomb";
this.help = "Bomb 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 bomb!");
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(Constants.VORTEX_EMOJI + " **Bomb** " + Constants.VORTEX_EMOJI)
.setEmbed(new EmbedBuilder()
.setColor(!event.isFromType(ChannelType.TEXT) ? Color.GRAY : event.getSelfMember().getColor())
.setDescription(target.getAsMention() + " was bombed. :bomb:")
.build())
.build());
}
}