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

The following examples show how to use net.dv8tion.jda.core.EmbedBuilder#setAuthor() . 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: 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 2
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 3
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 4
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 5
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 6
Source File: QuickPollCommand.java    From DiscordBlueBot with MIT License 6 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {
    String query = "";
    for (String arg : args) {
        query += arg + " ";
    }
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor()));
    builder.setAuthor(event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + " created a poll", null, event.getAuthor().getAvatarUrl());
    builder.addField("", ":grey_question: Question : " + "**" + query + "**", false);
    builder.setFooter("Vote by adding a reaction below !", null);

    event.getMessage().delete().queue();
    event.getTextChannel().sendMessage(builder.build()).queue();

    //Now retrieves the last message from BlueBot to add reactions
    List<Message> history = event.getTextChannel().getHistory().retrievePast(10).complete(); //arbitrary ammount
    for (Message msg : history) {
        if(msg.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) {
            msg.addReaction("\uD83D\uDC4D").queue();
            msg.addReaction("\ud83d\udc4e").queue();
            msg.addReaction("\uD83E\uDD37").queue();
            break;
        }
    }
}
 
Example 7
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 8
Source File: ListCmd.java    From Selfbot with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(String args, MessageReceivedEvent event) {
    Collection<String> list = emojis.getEmojiList();
    if(list.isEmpty())
    {
        tempReply("No custom emojis!", event);
        return;
    }
    
    EmbedBuilder builder = new EmbedBuilder();
    if(event.getGuild()!=null)
        builder.setColor(event.getGuild().getSelfMember().getColor());
    builder.setAuthor("Custom Emojis:", null, null);
    
    StringBuilder sbuilder = new StringBuilder();
    for(String ename: list)
    {
        String next = "\n`:"+ename+":` \u27A1 `"+emojis.getEmoji(ename)+"`";
        if(sbuilder.length()+next.length()>1985)
        {
            reply(builder.setDescription(sbuilder.toString().trim()).build(),event);
            builder.setAuthor(null,null,null);
            sbuilder = new StringBuilder();
        }
        sbuilder.append(next);
    }
    
    builder.setDescription(sbuilder.toString().trim());
    reply(builder.build(), event);
}
 
Example 9
Source File: InfoCommand.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(Reference.APP_NAME + " v" + Reference.APP_VERSION, null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
	embedBuilder.setColor(DiscordUtil.DEFAULT);
	embedBuilder.addField("Author", String.join(", ", Reference.AUTHORS), false);
	embedBuilder.addField("Source", Reference.SOURCE, false);
	embedBuilder.addField("Website", Reference.WEBSITE, 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);
}
 
Example 10
Source File: MessageUtils.java    From FlareBot with MIT License 5 votes vote down vote up
public static EmbedBuilder getEmbed() {
    if (cachedJDA == null || cachedJDA.getStatus() != JDA.Status.CONNECTED)
        cachedJDA = flareBot.getClient();

    EmbedBuilder defaultEmbed = new EmbedBuilder().setColor(ColorUtils.FLAREBOT_BLUE);

    // We really need to PR getAuthor and things into EmbedBuilder.
    if (cachedJDA != null) {
        defaultEmbed.setAuthor("FlareBot", "https://flarebot.stream", cachedJDA.getSelfUser().getEffectiveAvatarUrl());
    }

    return defaultEmbed.setColor(ColorUtils.FLAREBOT_BLUE);
}
 
Example 11
Source File: AudioQueue.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: CustomEmbedCommand.java    From DiscordBlueBot with MIT License 5 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {
    String query = "";
    Pattern subjectRegex = Pattern.compile("\\((.*?)\\)");
    String subject;

    for (String arg : args) {
        query += arg + " ";
    }

    Matcher subjectMatcher = subjectRegex.matcher(query);

    if (subjectMatcher.find()) {
        subject = subjectMatcher.group(1);
    } else {
        event.getTextChannel().sendMessage("Please provide a message").queue();
        return;
    }

    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor()));
    builder.setAuthor(event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + " : " + subject, null, event.getAuthor().getAvatarUrl());
    builder.addField("","**" + subject + "**", false);

    event.getMessage().delete().queue();
    event.getTextChannel().sendMessage(builder.build()).queue();
}
 
Example 13
Source File: SourcesCommand.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);
	embedBuilder.addField("Sources", String.join(",\n", DiscordBot.getInstance().getConfig().getAllowedSources()), false);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example 14
Source File: PingCommand.java    From DiscordBlueBot with MIT License 5 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor()));
    builder.setAuthor("I'm online !");
    builder.setDescription("Ping : " + event.getJDA().getPing() + " ms");

    event.getTextChannel().sendMessage(builder.build()).queue();
}
 
Example 15
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 16
Source File: MultiPollCommand.java    From DiscordBlueBot with MIT License 4 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {
    String query = "";
    String subject;
    String choicesList = "";
    ArrayList<String> choices = new ArrayList<>();
    Pattern subjectRegex = Pattern.compile("\\((.*?)\\)");
    Pattern choiceRegex = Pattern.compile("\\[(.*?)]");

    for (String arg : args) {
        query += arg + " ";
    }

    Matcher subjectMatcher = subjectRegex.matcher(query);
    Matcher choiceMatcher = choiceRegex.matcher(query);

    while (choiceMatcher.find()) {
        choices.add(choiceMatcher.group(1));
    }

    if (subjectMatcher.find()) {
        subject = subjectMatcher.group(1);
    } else {
        event.getTextChannel().sendMessage("Please provide a poll question/subject.").queue();
        return;
    }

    if(choices.size() < 2 || choices.size() > 10) { //At least 2 options and max 10
        event.getTextChannel().sendMessage("You can only propose from 2 to 10 options.").queue();
        return;
    }

    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor()));
    builder.setAuthor(event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + " created a poll", null, event.getAuthor().getAvatarUrl());
    builder.addField("", "Question : " + "**" + subject + "**", true);

    for(int i = 0; i < choices.size(); ++i) {
        if(i == 9) {
            choicesList = choicesList + "\uD83D\uDD1F " + choices.get(i); //Keycap 10 case
            break;
        }
        choicesList = choicesList + (i+1) + "⃣ " + choices.get(i) + "\n"; //damn these emojis made me mad
    }
    builder.addField("", choicesList, false);
    builder.setFooter("Vote by adding a reaction below !", null);

    event.getMessage().delete().queue();
    event.getTextChannel().sendMessage(builder.build()).queue();

    //Now retrieves the last message from BlueBot to add reactions
    List<Message> history = event.getTextChannel().getHistory().retrievePast(10).complete(); //arbitrary ammount
    for (Message msg : history) {
        if(msg.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) {
            for(int i = 0; i < choices.size(); ++i) {
                if(i == 9) {
                    msg.addReaction("\uD83D\uDD1F").queue(); //Keycap 10 case
                    break;
                }
                msg.addReaction(i+1 + "⃣").queue(); //damn these emojis made me mad
            }
            break;
        }
    }
}
 
Example 17
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 18
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 19
Source File: WhoisCommand.java    From DiscordBlueBot with MIT License 4 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {
    if(event.getMessage().getMentionedUsers().isEmpty()) {
        event.getTextChannel().sendMessage("No user mentioned.").queue();
        return;
    }
    User user = event.getMessage().getMentionedUsers().get(0);
    EmbedBuilder builder = new EmbedBuilder();
    builder.setAuthor("Information about " + user.getName() + "#" + user.getDiscriminator() , null, "http://i.imgur.com/880AyL6.png");
    builder.setColor(event.getGuild().getMemberById(user.getId()).getColor());
    builder.setThumbnail(user.getAvatarUrl());
    builder.addField(":id: User ID", user.getId(), true);

    String nickname = "None";
    if(event.getGuild().getMemberById(user.getId()).getNickname() != null) nickname = event.getGuild().getMemberById(user.getId()).getNickname();
    builder.addField(":information_source: Nickname", nickname, true);
    builder.addField(":computer: Status", event.getGuild().getMemberById(user.getId()).getOnlineStatus().name().toLowerCase(), true);

    String activity = "None";
    if(event.getGuild().getMemberById(user.getId()).getGame() != null) {
        activity = event.getGuild().getMemberById(user.getId()).getGame().getName();
    }
    builder.addField(":video_game: Activity", activity, true);

    String isOwner = "No";
    if( event.getGuild().getMemberById(user.getId()).isOwner()) {
        isOwner = "Yes";
    }
    builder.addField(":white_check_mark: Owner",  isOwner, true);

    String role = "No role";
    if(!event.getGuild().getMemberById(user.getId()).getRoles().isEmpty()) {
        role = event.getGuild().getMemberById(user.getId()).getRoles().get(0).getAsMention();
    }
    builder.addField(":medal: Highest role", role, true);

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy h:mm a");
    builder.addField(":clock2: Creation date", user.getCreationTime().format(formatter), true);
    builder.addField(":inbox_tray:  Join date", event.getGuild().getMemberById(user.getId()).getJoinDate().format(formatter), true);

    event.getTextChannel().sendMessage(builder.build()).queue();
}
 
Example 20
Source File: SettingsCommand.java    From DiscordBlueBot with MIT License 4 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {

    EmbedBuilder builder = new EmbedBuilder();
    builder.setAuthor("Settings for " + event.getGuild().getName(), "https://bluebot.pw", event.getJDA().getSelfUser().getAvatarUrl());
    builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor()));
    builder.setThumbnail(event.getGuild().getIconUrl());

    //Channels
    String defaultChannel = "`No channel specified`";
    String twitchChannel = MainBot.getTwitchChannel().get(event.getGuild().getId());
    if(twitchChannel == null) {
        twitchChannel = defaultChannel;
    } else {
        twitchChannel = event.getJDA().getTextChannelById(twitchChannel).getAsMention();
    }

    String userEventChannel = MainBot.getUserEventChannel().get(event.getGuild().getId());
    if(userEventChannel == null) {
        userEventChannel = defaultChannel;
    } else {
        userEventChannel = event.getJDA().getTextChannelById(userEventChannel).getAsMention();
    }

    String soundChannel = MainBot.getMusicChannel().get(event.getGuild().getId());
    if(soundChannel == null) {
        soundChannel = defaultChannel;
    } else {
        soundChannel = event.getJDA().getTextChannelById(soundChannel).getAsMention();
    }
    builder.addField("Channels", "Twitch channel : " + twitchChannel + "\nUser events channel : " + userEventChannel + "\nSound channel : " + soundChannel, false);

    //Functionalities
    String twitchNotif = "`enabled`";
    if(MainBot.getTwitchDisabled().contains(event.getGuild().getId())) {
        twitchNotif = "`disabled`";
    }

    String badWords = "`enabled`";
    if(MainBot.getBwDisabled().contains(event.getGuild().getId())) {
        badWords = "`disabled`";
    }

    String userEvents = "`enabled`";
    if(MainBot.getUserEventDisabled().contains(event.getGuild().getId())) {
        userEvents = "`disabled`";
    }

    String serverSb = "`dedicated`";
    if(MainBot.getServerSBDisabled().contains(event.getGuild().getId())) {
        serverSb = "`general`";
    }
    builder.addField("Functionalities : ", "Twitch notifications : " + twitchNotif + "\nBad words filter : " + badWords + "\nUser events : " + userEvents + "\nSoundboard : " + serverSb, false);

    //Autorole
    String autorole = MainBot.getAutoRoleList().get(event.getGuild().getId());
    if(autorole == null) {
        autorole = "`No role specified`";
    } else {
        autorole = event.getJDA().getRolesByName(autorole, true).get(0).getAsMention();
    }
    builder.addField("Autorole : ", autorole, false);

    //Prefix
    String prefix = MainBot.getPrefixes().get(event.getGuild().getId());
    if(prefix == null) {
        prefix = "!";
    }
    builder.addField("Current prefix : ", "Prefix is `" + prefix + "`", false);

    builder.setFooter("To edit these settings, use the channel, enable/disable, setautorole & setprefix commands", "https://i.imgur.com/VHtAEeP.png");

    event.getTextChannel().sendMessage(builder.build()).queue();
}