Search in sources :

Example 1 with EmbedBuilder

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

the class AudioPlayerLoadResultHandler method noMatches.

@Override
public void noMatches() {
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.ERROR);
    embedBuilder.setTitle("No matches found!", null);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

Example 2 with EmbedBuilder

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

the class AudioPlayerLoadResultHandler method loadFailed.

@Override
public void loadFailed(FriendlyException exception) {
    LogHelper.error("Failed to load - " + exception.getMessage());
    exception.printStackTrace();
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.ERROR);
    embedBuilder.addField("Failed to load", exception.getMessage(), false);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

Example 3 with EmbedBuilder

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

the class AudioQueue method playNext.

public void playNext() {
    Audio audio = getNext();
    if (audio == null) {
        DiscordBot.getInstance().getDiscord().getAudioPlayer().playTrack(null);
        return;
    }
    DiscordBot.getInstance().getDiscord().getAudioPlayer().playTrack(audio.getAudioTrack());
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(audio.getTextChannel().getJDA().getSelfUser().getName(), null, audio.getTextChannel().getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.DEFAULT);
    embedBuilder.addField("Now playing", audio.getAudioTrack().getInfo().title, false);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(audio.getTextChannel(), embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Audio(io.github.lxgaming.discordbot.entries.Audio)

Example 4 with EmbedBuilder

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

the class RemoveCommand 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()) {
        embedBuilder.setColor(DiscordUtil.ERROR);
        embedBuilder.setTitle("Invalid arguments!", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
    if (DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue() == null || DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().isEmpty()) {
        embedBuilder.setColor(DiscordUtil.ERROR);
        embedBuilder.setTitle("Queue is empty!", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
    if (arguments.get(0).equalsIgnoreCase("all")) {
        DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().clear();
        embedBuilder.setColor(DiscordUtil.SUCCESS);
        embedBuilder.setTitle("All songs from queue removed.", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
    try {
        int index = (Integer.parseInt(arguments.get(0)) - 1);
        if (index > DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().size() || index < 0) {
            throw new NumberFormatException();
        }
        Audio audio = DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().remove(index);
        embedBuilder.setColor(DiscordUtil.SUCCESS);
        if (audio != null && audio.getAudioTrack() != null) {
            embedBuilder.setTitle("Removed '" + audio.getAudioTrack().getInfo().title + "'.");
        } else {
            embedBuilder.setTitle("Removed '" + "Unknown" + "'.");
        }
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
    } catch (NumberFormatException ex) {
        embedBuilder.setColor(DiscordUtil.ERROR);
        embedBuilder.setTitle("Supplied value is outside the queue range!", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Audio(io.github.lxgaming.discordbot.entries.Audio)

Example 5 with EmbedBuilder

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

the class AudioPlayerLoadResultHandler method trackLoaded.

@Override
public void trackLoaded(AudioTrack audioTrack) {
    if (audioTrack == null) {
        return;
    }
    Audio audio = new Audio(getTextChannel(), getMember(), audioTrack);
    DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().add(audio);
    if (DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
        DiscordBot.getInstance().getDiscord().getAudioQueue().playNext();
    } else {
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
        embedBuilder.setColor(DiscordUtil.SUCCESS);
        embedBuilder.setTitle("'" + audio.getAudioTrack().getInfo().title + "' Has been added to the queue.", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
    }
    audio = null;
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Audio(io.github.lxgaming.discordbot.entries.Audio)

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