Search in sources :

Example 61 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class TrackScheduler method onTrackStart.

@Override
public void onTrackStart(AudioPlayer player, AudioTrack track) {
    if (manager.isShouldAnnounce()) {
        if (manager.getLastAnnouncementId() != null) {
            try {
                manager.getChannel().getMessageById(manager.getLastAnnouncementId()).queue(message -> message.delete().queue());
            } catch (Exception ignored) {
            }
        }
        User me = manager.getChannel().getGuild().getSelfMember().getUser();
        AudioTrackInfo info = track.getInfo();
        EmbedBuilder builder = MessageUtils.getDefaultEmbed(me);
        builder.setAuthor("Now playing " + info.title, "https://ardentbot.tk", "https://s-media-cache-ak0.pinimg" + ".com/736x/69/96/5c/69965c2849ec9b7148a5547ce6714735.jpg");
        builder.setThumbnail("https://s-media-cache-ak0.pinimg.com/736x/69/96/5c/69965c2849ec9b7148a5547ce6714735.jpg");
        builder.addField("Title", info.title, true).addField("Author", info.author, true).addField("Duration", Music.getDuration(track), true).addField("URL", info.uri, true).addField("Is Stream", String.valueOf(info.isStream), true);
        Message m = GuildUtils.getShard(manager.getChannel().getJDA()).help.sendEmbed(builder, manager.getChannel(), me);
        manager.setLastAnnouncementId(m.getId());
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) User(net.dv8tion.jda.core.entities.User) Message(net.dv8tion.jda.core.entities.Message) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) BotException(tk.ardentbot.core.misc.logging.BotException)

Example 62 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class Command method getHelp.

private EmbedBuilder getHelp(Guild guild, User author) throws Exception {
    Shard shard = GuildUtils.getShard(guild);
    EmbedBuilder embedBuilder = MessageUtils.getDefaultEmbed(author);
    String name = getName();
    name = name.substring(0, 1).toUpperCase() + name.substring(1);
    embedBuilder.setAuthor(name, shard.url, shard.bot.getAvatarUrl());
    StringBuilder description = new StringBuilder();
    description.append(getDescription());
    if (subcommands.size() > 0) {
        description.append("\n\n**Subcommands**\n");
        for (Subcommand subcommand : subcommands) {
            description.append(subcommand.getSyntax() + ": *" + subcommand.getDescription() + "*\n");
        }
        description.append("\n**Example**:");
        description.append("\n/" + name.toLowerCase() + " " + subcommands.get(0).getSyntax());
    }
    if (aliases != null && aliases.length > 0) {
        description.append("\n**Aliases**:\n");
        description.append(MessageUtils.listWithCommas(Arrays.asList(aliases)));
    }
    embedBuilder.setDescription(description.toString());
    return embedBuilder;
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Shard(tk.ardentbot.main.Shard)

Example 63 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class MessageUtils method getDefaultEmbed.

public static EmbedBuilder getDefaultEmbed(User author) {
    try {
        final Random random = new Random();
        final float hue = random.nextFloat();
        final float saturation = (random.nextInt(2000) + 1000) / 10000f;
        final float luminance = 2f;
        final Color color = Color.getHSBColor(hue, saturation, luminance);
        EmbedBuilder builder = new EmbedBuilder();
        builder.setColor(color);
        builder.setFooter("Requested by {0}".replace("{0}", author.getName() + "#" + author.getDiscriminator()), author.getAvatarUrl());
        return builder;
    } catch (Exception e) {
        new BotException(e);
        return null;
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Random(java.util.Random) BotException(tk.ardentbot.core.misc.logging.BotException) BotException(tk.ardentbot.core.misc.logging.BotException)

Example 64 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class Music method getMusicEmbed.

private EmbedBuilder getMusicEmbed(Guild guild, User user) throws Exception {
    EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
    builder.setAuthor(WordUtils.capitalize(getName()), getShard().url, guild.getSelfMember().getUser().getAvatarUrl());
    return builder;
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

Example 65 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class UD method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    Shard shard = GuildUtils.getShard(guild);
    if (args.length == 1) {
        sendTranslatedMessage("Search a word's definition from Urban Dictionary. Example: {0}ud test".replace("{0}", GuildUtils.getPrefix(guild)), channel, user);
    } else {
        GetRequest getRequest = Unirest.get("http://api.urbandictionary.com/v0/define?term=" + message.getRawContent().replace(GuildUtils.getPrefix(guild) + args[0] + " ", "").replaceAll(" ", "%20"));
        String json = "";
        try {
            json = getRequest.asJson().getBody().toString();
        } catch (UnirestException e) {
            e.printStackTrace();
        }
        UrbanDictionary definition = shard.gson.fromJson(json, UrbanDictionary.class);
        if (definition.getList().size() == 0) {
            sendTranslatedMessage("There aren't any definitions for this word!", channel, user);
        } else {
            EmbedBuilder builder = MessageUtils.getDefaultEmbed(message.getAuthor());
            UDList list = definition.getList().get(0);
            String def = "Definition";
            String author = "Author";
            String example = "Example";
            String link = "Link";
            String thumbsUp = "Thumbs Up";
            String thumbsDown = "Thumbs Down";
            String urbanDictionary = "Urban Dictionary";
            builder.setAuthor(urbanDictionary, shard.bot.getAvatarUrl(), shard.bot.getAvatarUrl());
            builder.setThumbnail("https://i.gyazo.com/6a40e32928743e68e9006396ee7c2a14.jpg");
            builder.setColor(Color.decode("#00B7BE"));
            String definitionText = list.getDefinition();
            String exampleText = list.getExample();
            if (definitionText.length() > 1024)
                definitionText = definitionText.substring(0, 1023);
            if (exampleText.length() > 1024)
                exampleText = exampleText.substring(0, 1023);
            builder.addField(def, definitionText, true);
            builder.addField(example, exampleText, true);
            builder.addField(thumbsUp, String.valueOf(list.getThumbsUp() + ":thumbsup:"), true);
            builder.addField(thumbsDown, String.valueOf(list.getThumbsDown() + ":thumbsdown:"), true);
            builder.addField(author, list.getAuthor(), true);
            builder.addField(link, list.getPermalink(), true);
            sendEmbed(builder, channel, user);
        }
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) UDList(tk.ardentbot.core.models.UDList) GetRequest(com.mashape.unirest.request.GetRequest) UnirestException(com.mashape.unirest.http.exceptions.UnirestException) UrbanDictionary(tk.ardentbot.core.models.UrbanDictionary) Shard(tk.ardentbot.main.Shard)

Aggregations

EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)73 Message (net.dv8tion.jda.core.entities.Message)15 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)13 ArrayList (java.util.ArrayList)12 Guild (net.dv8tion.jda.core.entities.Guild)11 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)11 MantaroData (net.kodehawa.mantarobot.data.MantaroData)11 DBGuild (net.kodehawa.mantarobot.data.entities.DBGuild)11 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)11 Color (java.awt.Color)10 User (net.dv8tion.jda.core.entities.User)10 Command (net.kodehawa.mantarobot.modules.Command)10 SimpleCommand (net.kodehawa.mantarobot.modules.commands.SimpleCommand)10 TimeUnit (java.util.concurrent.TimeUnit)9 Utils (net.kodehawa.mantarobot.utils.Utils)9 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 GuildData (net.kodehawa.mantarobot.data.entities.helpers.GuildData)8 CommandRegistry (net.kodehawa.mantarobot.modules.CommandRegistry)8 Module (net.kodehawa.mantarobot.modules.Module)8