当前位置: 首页>>代码示例>>Java>>正文


Java EmbedBuilder.setColor方法代码示例

本文整理汇总了Java中net.dv8tion.jda.core.EmbedBuilder.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java EmbedBuilder.setColor方法的具体用法?Java EmbedBuilder.setColor怎么用?Java EmbedBuilder.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.dv8tion.jda.core.EmbedBuilder的用法示例。


在下文中一共展示了EmbedBuilder.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logChannel

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
/**
 * Logs to the assigned log channel if it has been set
 */
public static void logChannel(LogLevel level, User author, String text, Object... args)
{
    if(MDCBot.logChannel != null && level.isHigherThanOrEqualTo(Config.get(EConfigs.LOG_LEVEL)))
    {
        if(author == null)
            author = MDCBot.jda.getSelfUser();
        EmbedBuilder message = new EmbedBuilder();
        message.setColor(level.colour);
        message.setAuthor(getFullUser(author), null, author.getEffectiveAvatarUrl());
        message.setTitle(level.toString());
        message.setDescription(String.format(text, args));
        message.setTimestamp(Instant.now());
        MDCBot.logChannel.sendMessage(message.build()).queue();
    }
}
 
开发者ID:thebrightspark,项目名称:MDC-Discord-Bot,代码行数:19,代码来源:Util.java

示例2: executeNowPlaying

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public Message executeNowPlaying() {
    if (!isBotInVoiceChannel())
        return message(error("Error!", "Bot is not in a voice channel."));
    VoiceChannel channel = getBotsVoiceChannel();
    if (parsedCommandInvocation.getMember().getVoiceState().getChannel() != channel)
        return message(error("Error!", "You have to be in the same voice channel as the bot."));
    if (getCurrentMusicManager().getPlayer().getPlayingTrack() == null) {
        return message(error("Error!", "Bot is playing nothing."));
    }
    AudioTrack track = getCurrentMusicManager().getPlayer().getPlayingTrack();
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor("Currently playing", track.getInfo().uri, null);
    embedBuilder.addField("Title", track.getInfo().title, true);
    embedBuilder.addField("Author", track.getInfo().author, true);
    embedBuilder.addField("Duration", (track.getInfo().isStream) ? "Stream" : getTimestamp(track.getDuration()), false);
    embedBuilder.setColor(Colors.COLOR_PRIMARY);
    parsedCommandInvocation.getMessage().getTextChannel().sendMessage(embedBuilder.build()).queue();
    return null;
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:20,代码来源:MusicManager.java

示例3: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    String[] args = parsedCommandInvocation.args;
    if (args.length < 3) {
        return new MessageBuilder().setEmbed(EmbedUtil.error("You have to use more arguments!", "Use at least 3 arguments.").build()).build();
    }
    String ownerMessage = parsedCommandInvocation.getMessage().getContentDisplay().replace(parsedCommandInvocation.getPrefix() + parsedCommandInvocation.getCommandInvocation(), "");
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor("Broadcast - Awaiting Confirmation", null, parsedCommandInvocation.getMessage().getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setDescription(ownerMessage);
    embedBuilder.setColor(Colors.COLOR_PRIMARY);
    Message confirmMessage = parsedCommandInvocation.getMessage().getTextChannel().sendMessage(embedBuilder.build()).complete();
    confirmMessage.addReaction("✅").queue();
    awaitingConfirm.put(confirmMessage.getIdLong(), ownerMessage);
    return null;
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:17,代码来源:CommandBroadcast.java

示例4: sendNowPaused

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public void sendNowPaused() {
    isPlaying = false;
    channel.getManager().setTopic("").queue();
    channel.deleteMessageById(idMessageNowPlaying).complete();

    idMessageNowPlaying = "";

    currentTrack = musicManager.player.getPlayingTrack();

    String title = currentTrack.getInfo().title;
    String position = getTimestamp(currentTrack.getPosition());
    String duration = getTimestamp(currentTrack.getDuration());

    String msg = String.format("[%s](%s)\n\n**Time:** \n[%s / %s]", title, currentTrack.getInfo().uri, position, duration);
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(server.getSelfMember().getColor());
    builder.setTitle("Paused:");
    builder.setDescription(msg);
    builder.setThumbnail(trackImgUrl);
    builder.setFooter(server.getSelfMember().getNickname() != null ? server.getSelfMember().getNickname() : server.getSelfMember().getEffectiveName(), server.getIconUrl());
    channel.getManager().setTopic("**Paused:** " + title).queue();
    Message theMessage = channel.sendMessage(builder.build()).complete();
    idMessageNowPlaying = theMessage.getId();
    try {
        channel.addReactionById(idMessageNowPlaying, "⏹").complete(true);
        channel.addReactionById(idMessageNowPlaying, "⏯").complete(true);
        channel.addReactionById(idMessageNowPlaying, "⏭").submit();
    } catch (Exception e) {
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:31,代码来源:NowPlaying.java

示例5: embedMessage

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
protected MessageEmbed embedMessage(CommandEvent event, String message, ResponseLevel level, String footer) {
    EmbedBuilder embedBuilder = new EmbedBuilder();
    User bot = event.getJDA().getSelfUser();
    embedBuilder.setAuthor(bot.getName() + " #" + bot.getDiscriminator(),
            null, bot.getEffectiveAvatarUrl());
    embedBuilder.setDescription(message);
    footer = footer == null ? (level == null ? ResponseLevel.DEFAULT.getFooter() : level.getFooter()) : footer;
    embedBuilder.setFooter(footer, null);
    embedBuilder.setTimestamp(event.getMessage().getCreationTime());
    embedBuilder.setColor(getResponseColor(level, event.getGuild(), bot));
    return embedBuilder.build();
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:13,代码来源:MCBCommand.java

示例6: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    //Set some Var´s
    Message message = parsedCommandInvocation.getMessage();
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Colors.COLOR_PRIMARY);
    builder.setAuthor(Info.BOT_NAME + " - Info", "https://rubicon.fun", message.getJDA().getSelfUser().getEffectiveAvatarUrl());
    StringBuilder authors = new StringBuilder();

    //Append Id´s on StringBuilder
    for (long authorId : Info.BOT_AUTHOR_IDS) {
        User authorUser = RubiconBot.getJDA().getUserById(authorId);
        if (authorUser == null) // TODO use alternative way that does not need to have the authors in cache.
            authors.append(authorId).append("\n");
        else
            authors.append(authorUser.getName()).append("#").append(authorUser.getDiscriminator()).append("\n");
    }
    //Set the Embed Values
    builder.addField("Bot Name", Info.BOT_NAME, true);
    builder.addField("Bot Version", Info.BOT_VERSION, true);
    builder.addField("Website", "[Link](" + Info.BOT_WEBSITE + ")", true);
    builder.addField("Bot Invite", "[Invite RubiconBot](https://discordapp.com/oauth2/authorize?client_id=380713705073147915&scope=bot&permissions=1898982486)", true);
    builder.addField("Github Link", "[Github Link](" + Info.BOT_GITHUB + ")", true);
    builder.addField("Patreon Link", "[RubiconBot Dev Team](https://www.patreon.com/rubiconbot)", true);
    builder.addField("discordbots.org", "[discordbots.org](https://discordbots.org/bot/380713705073147915)\n", true);
    builder.addField("Donators", String.join("\n", arrSupporter), true);
    builder.addField("Devs", authors.toString(), false);
    //Send Message and delete it after 2 Minutes
    return new MessageBuilder().setEmbed(builder.build()).build();
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:31,代码来源:CommandInfo.java

示例7: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    Set<User> list;
    EmbedBuilder builder = new EmbedBuilder();
    Color color;

    if(event.isFromType(ChannelType.PRIVATE))
    {
        color = Color.decode("#33ff00");
    }
    else
    {
        color = event.getGuild().getSelfMember().getColor();
    }

    try
    {
        list = db.getBlacklistedUsersList(event.getJDA());

        if(list.isEmpty())
        {
            event.reply("The list is empty!");
        }
        else
        {
            builder.setDescription(list.stream().map(u -> u.getName()+"#"+u.getDiscriminator()+" (ID: "+u.getId()+")").collect(Collectors.joining("\n")));
            builder.setFooter(event.getSelfUser().getName()+"'s Blacklisted Users", event.getSelfUser().getEffectiveAvatarUrl());
            builder.setColor(color);
            event.reply(builder.build());
        }
    }
    catch(Exception e)
    {
        event.replyError("Something went wrong when getting the blacklisted users list: \n```"+e+"```");
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:38,代码来源:BlacklistUsers.java

示例8: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(event.isFromType(ChannelType.TEXT) ? event.getSelfMember().getColor() : Color.GREEN);
    builder.setFooter(event.getSelfUser().getName(), event.getSelfUser().getAvatarUrl());
    builder.setTitle("The \"Game Bot\" Feature");
    builder.setDescription("The \"Game Bot\" feature is quite simple:");
    builder.addField("1.", "If you're playing a game, you just have to go in the server's game channel and react with :ok: in the bot channel", false);
    builder.addField("2.", "After that you'll be moved in a channel with the name of your game", false);
    builder.addField("3.", "If you leave the channel, it will automatically delete the channel", false);
    builder.setImage(Constant.gameBotExampleUrl);
    event.reply(builder.build());
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:14,代码来源:GameBotCommand.java

示例9: onGuildVoiceLeave

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    if (!isEventEnabled(event.getGuild(), LogEventKeys.VOICE))
        return;
    TextChannel textChannel = getLogChannel(event.getGuild());
    if (textChannel == null)
        return;

    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor("A member closed voice connection", null, event.getMember().getUser().getAvatarUrl());
    embedBuilder.setDescription("**" + event.getMember().getEffectiveName() + " (" + event.getMember().getUser().getId() + ")** left `" + event.getChannelLeft().getName() + "`");
    embedBuilder.setColor(evVoiceLog);
    sendLog(textChannel, embedBuilder);
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:15,代码来源:ServerLogHandler.java

示例10: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    Guild guild = event.getGuild();
    TextChannel modlog = db.getModlogChannel(guild);
    TextChannel serverlog = db.getServerlogChannel(guild);
    TextChannel welcome = db.getWelcomeChannel(guild);
    TextChannel leave = db.getLeaveChannel(guild);
    EmbedBuilder builder = new EmbedBuilder();
    String title = ":information_source: Settings of **"+event.getGuild().getName()+"**:";

    try
    {
        builder.addField("Modlog Channel: ", (modlog==null?"None":modlog.getAsMention()), true);
        builder.addField("Serverlog Channel: ", (serverlog==null?"None":serverlog.getAsMention()), true);
        builder.addField("Welcome Channel: ", (welcome==null?"None":welcome.getAsMention()), true);
        builder.addField("Leave Channel: ", (leave==null?"None":leave.getAsMention()), true);
        builder.setColor(event.getSelfMember().getColor());

        event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
    }
    catch(Exception e)
    {
        event.replyError("Something went wrong when getting the settings: \n```"+e+"```");
    }

}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:28,代码来源:ServerSettings.java

示例11: createChannels

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
private EmbedBuilder createChannels(Guild guild) {
    String[] channels = RubiconBot.getMySQL().getGuildValue(guild, "blacklist").split(",");
    StringBuilder channelnames = new StringBuilder();
    Arrays.asList(channels).forEach(c -> {
        TextChannel channel = guild.getTextChannelById(c);
        channelnames.append(channel.getName() + "`(" + channel.getId() + ")`, ");
    });
    channelnames.replace(channelnames.lastIndexOf(","), channelnames.lastIndexOf(",") + 1, "");
    EmbedBuilder embed = new EmbedBuilder();
    embed.setColor(Colors.COLOR_SECONDARY);
    embed.setTitle("Blacklisted channels");
    embed.setAuthor(guild.getName(), guild.getIconUrl());
    embed.setDescription(channelnames.toString());
    return embed;
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:16,代码来源:CommandBlacklist.java

示例12: onGuildVoiceJoin

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
public void onGuildVoiceJoin(GuildVoiceJoinEvent event) {
    if (!isEventEnabled(event.getGuild(), LogEventKeys.VOICE))
        return;
    TextChannel textChannel = getLogChannel(event.getGuild());
    if (textChannel == null)
        return;

    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor("A member created voice connection", null, event.getMember().getUser().getAvatarUrl());
    embedBuilder.setDescription("**" + event.getMember().getEffectiveName() + " (" + event.getMember().getUser().getId() + ")** joined `" + event.getChannelJoined().getName() + "`");
    embedBuilder.setColor(evVoiceLog);
    sendLog(textChannel, embedBuilder);
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:15,代码来源:ServerLogHandler.java

示例13: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    Message message = parsedCommandInvocation.getMessage();
    User info;
    String[] args = parsedCommandInvocation.getArgs();
    if (args.length > 0) {
        if (message.getMentionedUsers().size() > 0)
            info = message.getMentionedUsers().get(0);
        else {
            return createHelpMessage();
        }
    } else {
        info = message.getAuthor();
    }

    Member user = message.getGuild().getMember(info);
    StringBuilder rawRoles = new StringBuilder();
    user.getRoles().forEach(r -> rawRoles.append(r.getName()).append(", "));
    StringBuilder roles = new StringBuilder(rawRoles.toString());
    if (!user.getRoles().isEmpty())
        roles.replace(rawRoles.lastIndexOf(","), roles.lastIndexOf(",") + 1, "");
    EmbedBuilder userinfo = new EmbedBuilder();
    userinfo.setColor(Colors.COLOR_PRIMARY);
    userinfo.setTitle("User information of " + user.getUser().getName());
    userinfo.setThumbnail(info.getAvatarUrl());
    userinfo.addField("Nickname", user.getEffectiveName(), false);
    userinfo.addField("User id", info.getId(), false);
    userinfo.addField("Status", user.getOnlineStatus().toString().replace("_", ""), false);
    if (user.getGame() != null)
        userinfo.addField("Game", user.getGame().toString(), false);
    userinfo.addField("Guild join date", formatDate(user.getJoinDate()), false);
    userinfo.addField("Roles", "`" + roles.toString() + "`", false);
    userinfo.addField("Discord join date", formatDate(info.getCreationTime()), false);
    userinfo.addField("Avatar url", info.getAvatarUrl(), true);
    userinfo.addField("--- RubiconBot Stats ---", "" +
            "Level: " + RubiconBot.getMySQL().getUserValue(user.getUser(), "level") + "\n" +
            "Ruby's: " + RubiconBot.getMySQL().getUserValue(user.getUser(), "money"), true);
    return new MessageBuilder().setEmbed(userinfo.build()).build();
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:40,代码来源:CommandUserInfo.java

示例14: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
public void execute(MessageReceivedEvent event, String[] args) {
    EmbedBuilder eb = new EmbedBuilder();
    eb.setColor(Color.getHSBColor(217,65,0));
    eb.setAuthor("LegendaryBot Stats","https://github.com/greatman/legendarybot","https://cdn.discordapp.com/app-icons/267134720700186626/ba3e3856b551e0c425280571db7746ef.jpg");

    RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
    String uptime = DurationFormatUtils.formatDuration(mxBean.getUptime(), "d") + " days " + DurationFormatUtils.formatDuration(mxBean.getUptime()," HH:mm:ss");

    //Getting the runtime reference from system
    Runtime runtime = Runtime.getRuntime();
    int mb = 1024*1024;


    eb.addField(":homes:Guilds", plugin.getGuildCount() + "",true);
    eb.addField(":busts_in_silhouette: Members", plugin.getMemberCount() + "", true);
    eb.addField(":notepad_spiral:Text Channels", plugin.getTextChannelCount() + "", true);
    eb.addField(":loudspeaker:Voice Channels", plugin.getVoiceChannelCount() + "", true);
    eb.addField("Legendary checks", plugin.getLegendaryCount() + "", true);
    eb.addField(":timer:Uptime", uptime, true);

    eb.addField(":computer:Memory", "U: " +plugin.getUsedRam() + "MB / M: " + runtime.maxMemory() / mb + "MB", true);
    eb.addField(":speaker:Audio connections", plugin.getAudioConnections() + "", true);

    eb.addField(":musical_note: Song Queue", plugin.getSongQueue() + "", true);

    eb.setColor(Color.BLUE);

    event.getChannel().sendMessage(eb.build()).queue();


}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:33,代码来源:BotStatsCommands.java

示例15: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    String title = ":information_source: Stats of **"+event.getSelfUser().getName()+"**:";
    Color color;
    String os = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getName();
    String arch = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getArch();
    String version = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getVersion();
    os = os+" "+arch+" "+version;
    int cpus = Runtime.getRuntime().availableProcessors();
    String processCpuLoad = new DecimalFormat("###.###%").format(ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getProcessCpuLoad());
    String systemCpuLoad = new DecimalFormat("###.###%").format(ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getSystemCpuLoad());
    long ramUsed = ((Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()) / (1024 * 1024));

    if(event.isFromType(ChannelType.PRIVATE))
        color = Color.decode("#33ff00");
    else
        color = event.getGuild().getSelfMember().getColor();
    
    EmbedBuilder builder = new EmbedBuilder();
    builder.addField("<:windows:371075985996775425> OS: ", os, true);
    builder.addField(":computer: RAM usage: ", ramUsed+"MB", true);
    builder.addField(":gear: CPU usage: ", processCpuLoad+" / "+systemCpuLoad+" ("+cpus+" Cores)", true);
    builder.addField(":map: Guilds: ", ""+event.getJDA().getGuilds().size() , true);
    builder.addField(":speech_balloon: Text Channels: ", ""+event.getJDA().getTextChannels().size(), true);
    builder.addField(":speaker: Voice Channels: ", ""+event.getJDA().getVoiceChannels().size(), true);
    builder.addField(":bust_in_silhouette: Users: ", ""+event.getJDA().getUsers().size(), true);
    builder.setFooter(event.getSelfUser().getName(), event.getSelfUser().getEffectiveAvatarUrl());
    builder.setColor(color);
    event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:32,代码来源:Stats.java


注:本文中的net.dv8tion.jda.core.EmbedBuilder.setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。