Search in sources :

Example 36 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)

Example 37 with EmbedBuilder

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

the class PlayCommand 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);
    if (member.getGuild().getAudioManager().getConnectedChannel() == null) {
        embedBuilder.setColor(DiscordUtil.ERROR);
        embedBuilder.setTitle("Not connected to voice channel!", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
    if (arguments == null || arguments.isEmpty()) {
        if (DiscordBot.getInstance().getDiscord().getAudioPlayer().isPaused()) {
            DiscordBot.getInstance().getDiscord().getAudioPlayer().setPaused(false);
            embedBuilder.setColor(DiscordUtil.SUCCESS);
            embedBuilder.setTitle("Playback resumed.", null);
        } else {
            DiscordBot.getInstance().getDiscord().getAudioPlayer().setPaused(true);
            embedBuilder.setColor(DiscordUtil.WARNING);
            embedBuilder.setTitle("Playback paused.", null);
        }
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
    for (Iterator<String> iterator = arguments.iterator(); iterator.hasNext(); ) {
        String string = iterator.next();
        if (!string.startsWith("https://")) {
            continue;
        }
        DiscordBot.getInstance().getDiscord().getAudioPlayerManager().loadItem(string, new AudioPlayerLoadResultHandler(textChannel, member));
        embedBuilder.setColor(DiscordUtil.SUCCESS);
        embedBuilder.setTitle("Processing...", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) AudioPlayerLoadResultHandler(io.github.lxgaming.discordbot.discord.handlers.AudioPlayerLoadResultHandler)

Example 38 with EmbedBuilder

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

the class InfoCommand method execute.

@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(Reference.APP_NAME + " v" + Reference.APP_VERSION, null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.DEFAULT);
    embedBuilder.addField("Author", "LX_Gaming", false);
    embedBuilder.addField("Source", "https://github.com/LXGaming/DiscordBot/", false);
    embedBuilder.addField("Dependencies", "" + "\n- " + Reference.JDA_NAME + " v" + Reference.JDA_VERSION + "\n- " + Reference.LAVA_NAME + " v" + Reference.LAVA_VERSION, false);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

Example 39 with EmbedBuilder

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

the class HelpCommand 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);
    embedBuilder.setTitle("Commands", null);
    for (Iterator<ICommand> iterator = DiscordBot.getInstance().getDiscord().getCommand().getRegisteredCommands().iterator(); iterator.hasNext(); ) {
        ICommand command = iterator.next();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Description - " + command.getDescription() + "\n");
        stringBuilder.append("Usage - " + command.getUsage() + "\n");
        if (command.getAliases() != null && !command.getAliases().isEmpty()) {
            stringBuilder.append("Aliases - " + String.join(", ", command.getAliases()));
        }
        embedBuilder.addField(command.getName(), stringBuilder.toString(), false);
    }
    embedBuilder.setFooter("<> = Required Argument, [] = Optional Argument", null);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) ICommand(io.github.lxgaming.discordbot.entries.ICommand)

Example 40 with EmbedBuilder

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

the class VolumeCommand 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);
    if (arguments != null && !arguments.isEmpty()) {
        try {
            int volume = Integer.parseInt(arguments.get(0));
            if (volume > 100 || volume < 0) {
                volume = DiscordBot.getInstance().getDiscord().getAudioPlayer().getVolume();
            }
            DiscordBot.getInstance().getDiscord().getAudioPlayer().setVolume(volume);
            embedBuilder.setColor(DiscordUtil.SUCCESS);
        } catch (NumberFormatException ex) {
            embedBuilder.setColor(DiscordUtil.ERROR);
            embedBuilder.setTitle("Invalid volume!", null);
            DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
            return;
        }
    }
    embedBuilder.setTitle("Volume - " + DiscordBot.getInstance().getDiscord().getAudioPlayer().getVolume(), null);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

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