Newer
Older
CrashLogBot / src / main / java / net / romvoid / crashbot / commands / GitCommand.java
package net.romvoid.crashbot.commands;

import java.util.concurrent.TimeUnit;

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.romvoid.crashbot.Bot;
import net.romvoid.crashbot.utilities.EmbedUtil;

public class GitCommand extends Command {

    public GitCommand() {
        this.name = "git";
        this.help = "Returns the GitBucket repository for the bot";
        this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS};
        this.guildOnly = false;
    }

    @Override
    protected void execute(CommandEvent event) {
        Bot.LOG.info(event.getAuthor().getName() + " invoked command " + this.name);

        MessageChannel channel = event.getChannel();
        EmbedBuilder embed = EmbedUtil.embed("CrashBot GitBucket",
                "Have an issue? Or want to contribute? Head on over to my GitBucket Repo!");
        embed.addField("GitBucket Link", "[GitBucket Repository](http://gitbucket.mfnd.ru/y.varenkov/CrashLogBot)", false);
        Message msg = EmbedUtil.message(embed);
        EmbedUtil.sendAndDeleteOnGuilds(channel, msg, 2, TimeUnit.MINUTES);
        event.getMessage().delete().queue();
    }
}