Java Code Examples for net.dv8tion.jda.core.EmbedBuilder#setTitle()

The following examples show how to use net.dv8tion.jda.core.EmbedBuilder#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagedEmbedBuilder.java    From FlareBot with MIT License 6 votes vote down vote up
/**
 * Gets the {@link MessageEmbed} for a specified page.
 *
 * @param page The page to get an embed.
 * @return the {@link MessageEmbed} page.
 */
public MessageEmbed getEmbed(int page) {
    EmbedBuilder pageEmbed = new EmbedBuilder().setColor(ColorUtils.FLAREBOT_BLUE);
    if (title != null)
        pageEmbed.setTitle(title);
    if(useGroups) {
        int start = groupsPerPage * (page);
        int end = Math.min(start + groupsPerPage, groupTotal);
        int num = start;
        List<PaginationList<T>.PageGroup> groups = list.getGroups().subList(start, end);
        for (PaginationList.PageGroup group : groups) {
            pageEmbed.addField(groupPrefix + num, group.getGroupAsString(), false);
            num++;
        }
    } else {
        pageEmbed.setDescription((hasCodeBlock ? "```" + codeBlock + "\n" : "") + list.getPage(page) + (hasCodeBlock ? "\n```" : ""));
    }
    if (pageCounts) {
        pageEmbed.addField("Page", String.valueOf(page + 1), true);
        pageEmbed.addField("Total Pages", String.valueOf(pageTotal), true);
    }
    pageEmbed.setColor(color);
    return pageEmbed.build();
}
 
Example 2
Source File: ShuffleCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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 (DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue() == null || DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().size() < 2) {
		embedBuilder.setColor(DiscordUtil.ERROR);
		embedBuilder.setTitle("The current queue is not big enough to shuffle!", null);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
	
	Collections.shuffle(DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue(), new Random(System.nanoTime()));
	embedBuilder.setColor(DiscordUtil.SUCCESS);
	embedBuilder.setTitle("Current queue shuffled.", null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example 3
Source File: AudioPlayerLoadResultHandler.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
	for (Iterator<AudioTrack> iterator = audioPlaylist.getTracks().iterator(); iterator.hasNext();) {
		AudioTrack audioTrack = iterator.next();
		if (audioTrack == null) {
			continue;
		}
		
		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 {
			LogHelper.debug("'" + audio.getAudioTrack().getInfo().title + "' Has been added to the queue.");
		}
		audio = null;
	}
	LogHelper.debug(audioPlaylist.getTracks().size() + " Songs have been added to the queue.");
	EmbedBuilder embedBuilder = new EmbedBuilder();
	embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
	embedBuilder.setColor(DiscordUtil.SUCCESS);
	embedBuilder.setTitle(audioPlaylist.getTracks().size() + " Songs have been added to the queue.", null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example 4
Source File: NowPlayingCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 5
Source File: AudioPlayerLoadResultHandler.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 6
Source File: HelpCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 7
Source File: VolumeCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 8
Source File: StopCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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 (DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
		embedBuilder.setColor(DiscordUtil.ERROR);
		embedBuilder.setTitle("Player is not playing anything!", null);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
	
	DiscordBot.getInstance().getDiscord().getAudioPlayer().stopTrack();
	embedBuilder.setColor(DiscordUtil.SUCCESS);
	embedBuilder.setTitle("Track stopped.", null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example 9
Source File: SkipCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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 (DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatSong()) {
		embedBuilder.setColor(DiscordUtil.WARNING);
		DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatSong(false);
		embedBuilder.setTitle("Repeat is now off, Skipping...", null);
	} else {
		embedBuilder.setColor(DiscordUtil.SUCCESS);
		embedBuilder.setTitle("Skipping...", null);
	}
	
	DiscordBot.getInstance().getDiscord().getAudioQueue().playNext();
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example 10
Source File: QueryCommand.java    From FlareBot with MIT License 5 votes vote down vote up
@Override
public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
    try {
        CassandraController.runUnsafeTask(conn -> {
            ResultSet set = conn.execute(MessageUtils.getMessage(args, 0));
            List<String> header = new ArrayList<>();
            List<List<String>> table = new ArrayList<>();
            int columnsCount = set.getColumnDefinitions().size();
            for (int i = 0; i < columnsCount; i++) {
                header.add(set.getColumnDefinitions().getName(i));
            }
            for (Row setRow : set) {
                List<String> row = new ArrayList<>();
                for (int i = 0; i < columnsCount; i++) {
                    String value = setRow.getObject(i).toString();
                    row.add(value.substring(0, Math.min(30, value.length())));
                }
                table.add(row);
            }
            String output = MessageUtils.makeAsciiTable(header, table, null);
            if (output.length() < 2000) {
                channel.sendMessage(output).queue();
            } else {
                MessageUtils.sendErrorMessage("The query result set was very large, it has been posted to paste [here](" + MessageUtils
                        .paste(output) + ")", channel, sender);
            }
        });
    } catch (QueryExecutionException | QueryValidationException e) {
        EmbedBuilder eb = new EmbedBuilder();
        eb.setTitle("Failed to execute query");
        eb.addField("Error", "```\n" + e.getMessage() + "\n```", false);
        channel.sendMessage(eb.build()).queue();
    }
}
 
Example 11
Source File: AudioPlayerLoadResultHandler.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: ClearCommand.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: JoinCommand.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
@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;
	}
	
	List<VoiceChannel> voiceChannels = member.getGuild().getVoiceChannelsByName(arguments.get(0), false);
	if (voiceChannels.size() < 1) {
		embedBuilder.setColor(DiscordUtil.ERROR);
		embedBuilder.setTitle("Unable to find specified voice channel!", null);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
	
	if (member.getGuild().getAudioManager().getConnectedChannel() != null) {
		member.getGuild().getAudioManager().closeAudioConnection();
	}
	
	try {
		member.getGuild().getAudioManager().openAudioConnection(voiceChannels.get(0));
		embedBuilder.setColor(DiscordUtil.SUCCESS);
		embedBuilder.setTitle("Joined channel '" + voiceChannels.get(0).getName() + "'.", null);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
	} catch (RuntimeException ex) {
		embedBuilder.setColor(DiscordUtil.ERROR);
		embedBuilder.addField("Cannot join channel '" + voiceChannels.get(0).getName() + "'!", ex.getMessage(), false);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
	}
}
 
Example 14
Source File: PlayCommand.java    From DiscordBot with Apache License 2.0 4 votes vote down vote up
@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;
	}
	
	embedBuilder.setColor(DiscordUtil.SUCCESS);
	for (Iterator<String> iterator = arguments.iterator(); iterator.hasNext();) {
		String string = iterator.next();
		
		URL url = DiscordUtil.encodeURL(string);
		if (url == null) {
			embedBuilder.setColor(DiscordUtil.WARNING);
			embedBuilder.addField("Invalid URL!", string, false);
			continue;
		}
		
		if (!DiscordBot.getInstance().getConfig().getAllowedSources().contains(url.getHost())) {
			embedBuilder.setColor(DiscordUtil.WARNING);
			embedBuilder.addField("This source is not allowed!", string, false);
			continue;
		}
		
		DiscordBot.getInstance().getDiscord().getAudioPlayerManager().loadItem(string, new AudioPlayerLoadResultHandler(textChannel, member));
		embedBuilder.addField("Processing", string, false);
	}
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example 15
Source File: RepeatCommand.java    From DiscordBot with Apache License 2.0 4 votes vote down vote up
@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.DEFAULT);
		embedBuilder.addField("Repeat Song", "" + DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatSong(), true);
		embedBuilder.addField("Repeat Queue", "" + DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatQueue(), true);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
	
	if (arguments.get(0).equalsIgnoreCase("song")) {
		if (DiscordBot.getInstance().getDiscord().getAudioPlayer().isPaused() || DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
			embedBuilder.setColor(DiscordUtil.ERROR);
			embedBuilder.setTitle("No song playing!", null);
			DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
			return;
		}
		
		if (DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatSong()) {
			DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatSong(false);
			embedBuilder.setColor(DiscordUtil.WARNING);
			embedBuilder.setTitle("No longer repeating current song.", null);
		} else {
			DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatSong(true);
			embedBuilder.setColor(DiscordUtil.SUCCESS);
			embedBuilder.setTitle("Repeating current song.", null);
		}
		
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
	
	if (arguments.get(0).equalsIgnoreCase("queue")) {
		if (DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue() == null || DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().isEmpty()) {
			embedBuilder.setColor(DiscordUtil.ERROR);
			embedBuilder.setTitle("No song in queue!", null);
			DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
			return;
		}
		
		if (DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatQueue()) {
			DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatQueue(false);
			embedBuilder.setColor(DiscordUtil.WARNING);
			embedBuilder.setTitle("No longer repeating current queue.", null);
		} else {
			DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatQueue(false);
			embedBuilder.setColor(DiscordUtil.SUCCESS);
			embedBuilder.setTitle("Repeating current queue.", null);
		}
		
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
}
 
Example 16
Source File: RemoveCommand.java    From DiscordBot with Apache License 2.0 4 votes vote down vote up
@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;
	}
}
 
Example 17
Source File: ServerInfoCommand.java    From FlareBot with MIT License 4 votes vote down vote up
private void sendGuildInfo(Guild guild, TextChannel channel) {
    EmbedBuilder eb = new EmbedBuilder();
    eb.setTitle(guild.getName());
    eb.setThumbnail(guild.getIconUrl());
    eb.addField("Users", "**Total:** " +
            guild.getMembers().size() + "\n" +
            "\n" +
            "**Online:** " +
            guild.getMembers().stream().filter(member -> !member.getOnlineStatus().equals(OnlineStatus.OFFLINE)).count() + "\n" +
            "\n" +
            "**Owner:** " +
            MessageUtils.getTag(guild.getOwner().getUser()), true);
    String afk = guild.getAfkChannel() == null ? "" :
            "**AFK:**\n" +
                    "Channel: " +
                    guild.getAfkChannel().getName() + "\n" +
                    "\n" +
                    "Timeout: " +
                    FormatUtils.formatTime(guild.getAfkTimeout().getSeconds(), TimeUnit.SECONDS, true, false);
    eb.addField("Channels", "**Text**\n" +
            "Total: " +
            guild.getTextChannels().size() + "\n" +
            "\n" +
            "**Voice**\n" +
            "Total: " +
            guild.getVoiceChannels().size() + "\n" +
            "\n" +
            "Active: " +
            guild.getVoiceChannels().stream().filter(voiceChannel -> voiceChannel.getMembers().size() > 0).count() + "\n" +
            "\n" + afk, true);
    eb.addField("Misc info", "**Creation time:** " +
            guild.getCreationTime().toLocalDateTime().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + " UTC\n" +
            "\n" +
            "**Roles:** " +
            guild.getRoles().size() + "\n" +
            "\n" +
            "**Server region:** " +
            guild.getRegion().getName() + "\n" +
            "\n" +
            "**Verification Level:** " +
            GeneralUtils.getVerificationString(guild.getVerificationLevel()), true);
    eb.setFooter("ID: " + guild.getId(), null);
    eb.setColor(Color.CYAN);
    channel.sendMessage(eb.build()).queue();
}