Search in sources :

Example 66 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project MantaroBot by Mantaro.

the class EmbedJSON method gen.

public MessageEmbed gen(GenericGuildMemberEvent event) {
    EmbedBuilder embed = new EmbedBuilder();
    if (title != null)
        embed.setTitle(title, titleUrl);
    if (description != null)
        embed.setDescription(description);
    if (author != null)
        embed.setAuthor(author, authorUrl, authorImg);
    if (footer != null)
        embed.setFooter(footer, footerImg);
    if (image != null)
        embed.setImage(image);
    if (thumbnail != null)
        embed.setThumbnail(thumbnail);
    if (color != null) {
        Color c = null;
        try {
            c = (Color) Color.class.getField(color).get(null);
        } catch (Exception ignored) {
            String colorLower = color.toLowerCase();
            if (colorLower.equals("member")) {
                c = event.getMember().getColor();
            } else if (colorLower.matches("#?(0x)?[0123456789abcdef]{1,6}")) {
                try {
                    c = Color.decode(colorLower.startsWith("0x") ? colorLower : "0x" + colorLower);
                } catch (Exception ignored2) {
                }
            }
        }
        if (c != null)
            embed.setColor(c);
    }
    fields.forEach(f -> {
        if (f == null) {
            embed.addBlankField(false);
        } else if (f.value == null) {
            embed.addBlankField(f.inline);
        } else {
            embed.addField(f.name == null ? "" : f.name, f.value, f.inline);
        }
    });
    return embed.build();
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Color(java.awt.Color)

Example 67 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project MOOTBoot by LeshDev.

the class botInfo method onMessageReceived.

public void onMessageReceived(MessageReceivedEvent e) {
    Message msg = e.getMessage();
    EmbedBuilder eB = new EmbedBuilder();
    if (!msg.getRawContent().startsWith("-info") || bannedList.black.contains(e.getAuthor().getIdLong()) || e.getAuthor().isBot()) {
        return;
    }
    System.out.println(e.getAuthor() + " used the following command: -info");
    eB.setAuthor(lib.bot_name, null, lib.bot_image);
    eB.addField("Creator", "<@!155704314638106624>", true);
    eB.addField("GitHub", "[MOOTBooT](https://github.com/LeshDev/MOOTBoot/tree/master/src/de/lesh/mootboot)", true);
    eB.addField("Safe since", "28.05.2017 - 21:51", true);
    eB.addField("Version", lib.version, true);
    eB.setThumbnail(lib.bot_image);
    eB.setColor(java.awt.Color.GREEN);
    e.getChannel().sendMessage(eB.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Message(net.dv8tion.jda.core.entities.Message)

Example 68 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project MOOTBoot by LeshDev.

the class botPing method onMessageReceived.

public void onMessageReceived(MessageReceivedEvent e) {
    Message msg = e.getMessage();
    if (!msg.getRawContent().startsWith("-ping") || bannedList.black.contains(e.getAuthor().getIdLong())) {
        return;
    }
    EmbedBuilder eB = new EmbedBuilder();
    long start = System.currentTimeMillis();
    eB.setAuthor(">> Bot Ping", null, lib.bot_image);
    eB.addField("Ping", "**Bot: **" + e.getJDA().getPing() + "ms\n" + "**User: **" + (System.currentTimeMillis() - start) + "ms", false);
    eB.setColor(java.awt.Color.MAGENTA);
    e.getChannel().sendMessage(eB.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Message(net.dv8tion.jda.core.entities.Message)

Example 69 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project DiscordBot by LXGaming.

the class ClearCommand method execute.

@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
    DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatQueue(false);
    DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatSong(false);
    DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().clear();
    DiscordBot.getInstance().getDiscord().getAudioPlayer().stopTrack();
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.DEFAULT);
    embedBuilder.setTitle("Queue cleared.", null);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

Example 70 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project DiscordBot by LXGaming.

the class NowPlayingCommand method execute.

@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.DEFAULT);
    AudioTrack audioTrack = DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack();
    if (audioTrack == null) {
        embedBuilder.setTitle("Nothing is currently playing.", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
    embedBuilder.addField("Now playing", audioTrack.getInfo().title, false);
    embedBuilder.setFooter(DiscordUtil.getTimestamp(audioTrack.getPosition()) + " / " + DiscordUtil.getTimestamp(audioTrack.getDuration()), null);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

Aggregations

EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)128 Message (net.dv8tion.jda.core.entities.Message)26 List (java.util.List)24 ArrayList (java.util.ArrayList)22 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)22 User (net.dv8tion.jda.core.entities.User)20 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)20 Collectors (java.util.stream.Collectors)19 MantaroData (net.kodehawa.mantarobot.data.MantaroData)19 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)17 Utils (net.kodehawa.mantarobot.utils.Utils)17 TimeUnit (java.util.concurrent.TimeUnit)16 Permission (net.dv8tion.jda.core.Permission)15 Subscribe (com.google.common.eventbus.Subscribe)13 Color (java.awt.Color)13 Guild (net.dv8tion.jda.core.entities.Guild)12 TextChannel (net.dv8tion.jda.core.entities.TextChannel)12 SimpleCommand (net.kodehawa.mantarobot.core.modules.commands.SimpleCommand)12 DiscordUtils (net.kodehawa.mantarobot.utils.DiscordUtils)12 java.awt (java.awt)11