當前位置: 首頁>>代碼示例>>Java>>正文


Java EmbedBuilder.build方法代碼示例

本文整理匯總了Java中net.dv8tion.jda.core.EmbedBuilder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java EmbedBuilder.build方法的具體用法?Java EmbedBuilder.build怎麽用?Java EmbedBuilder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.dv8tion.jda.core.EmbedBuilder的用法示例。


在下文中一共展示了EmbedBuilder.build方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: displayTheme

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
/**
 * Display theme.
 *
 * @param themeID the id
 * @return the message embed
 */
public MessageEmbed displayTheme(Integer themeID) {

    if (themeID == null || themeID <= 0) {
        return null;
    }

    Theme themeDesc = dbMan.sqlGetThemeDesc(themeID);

    EmbedBuilder newEmbed = new EmbedBuilder();
    newEmbed.setAuthor(themeDesc.getName(), null, themeDesc.getAvatar());
    newEmbed.setThumbnail(themeDesc.getAvatar());
    newEmbed.setTitle("Author: " + themeDesc.getAuthor());
    newEmbed.setDescription(themeDesc.getDesc());
    newEmbed.addField("Created on: ", themeDesc.getDateCreated().toString(), true);
    newEmbed.addField("Last Modified On: ", themeDesc.getDateModified().toString(), true);
    newEmbed.addField("Theme played: ", themeDesc.getPlayedCount().toString(), true);
    newEmbed.setFooter("Theme ID: " + themeID.toString(), null);

    return newEmbed.build();

}
 
開發者ID:IANetworks,項目名稱:Ducky-Mc-Duckerson,代碼行數:28,代碼來源:Werewolf.java

示例2: reply

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
@Override
public void reply(Config config, CommandEvent commandEvent, String message, int numberOfSecondsBeforeRemove,
                  LocaleService localeService) {
    Validate.isTrue(numberOfSecondsBeforeRemove > 5);
    if (config != null && config.getReplyInDmWhenPossible()) {
        commandEvent.replyInDM(message);
        commandEvent.reactSuccess();
        handleOriginMessage(commandEvent);
    } else {
        commandEvent.reactSuccess();
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final String msgRemoveText = localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN,
                localeService.getLocaleForUser(commandEvent.getAuthor()), "" +
                        numberOfSecondsBeforeRemove);

        embedBuilder.setFooter(msgRemoveText, null);
        final MessageEmbed messageEmbed = embedBuilder.build();
        replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed, numberOfSecondsBeforeRemove,
                TimeUnit.SECONDS);
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:25,代碼來源:CleanUpMostFeedbackStrategy.java

示例3: run

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
    if (embed == null) {
        JDA shard = event.getJDA();
        DSLContext database = bot.getDatabase();
        Guild guild = event.getGuild();
        EmbedBuilder builder = new EmbedBuilder();
        builder.setAuthor("Safety Jim - Commands", null, shard.getSelfUser().getAvatarUrl());
        builder.setDescription(getUsageTexts(bot, DatabaseUtils.getGuildSettings(database, guild).getPrefix()));
        builder.setColor(new Color(0x4286F4));

        embed = builder.build();
    }

    DiscordUtils.successReact(bot, event.getMessage());
    DiscordUtils.sendMessage(event.getChannel(), embed);
    return false;
}
 
開發者ID:Samoxive,項目名稱:SafetyJim,代碼行數:19,代碼來源:Help.java

示例4: replyAndKeep

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
@Override
public void replyAndKeep(Config config, CommandEvent commandEvent, String message) {
    if (config != null && config.getReplyInDmWhenPossible()) {
        commandEvent.replyInDM(message);
        commandEvent.reactSuccess();
        handleOriginMessage(commandEvent);
    } else {
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final MessageEmbed messageEmbed = embedBuilder.build();
        replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent,
                messageEmbed, BotServerMain.timeToRemoveFeedbackInSeconds * 3, TimeUnit.SECONDS);
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:17,代碼來源:CleanUpMostFeedbackStrategy.java

示例5: replyError

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
@Override
public void replyError(Config config, CommandEvent commandEvent, Throwable throwable, LocaleService localeService) {
    if (config != null && config.getReplyInDmWhenPossible()) {
        commandEvent.replyInDM(throwable.getMessage());
        commandEvent.reactError();
    } else {
        commandEvent.reactError();
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(throwable.getMessage());
        final String msgRemoveText = localeService.getMessageFor(LocaleService.ERROR_KEEP_CHAT_CLEAN,
                localeService.getLocaleForUser(commandEvent.getAuthor()),
                String.valueOf(BotServerMain.timeToRemoveFeedbackInSeconds));
        embedBuilder.setFooter(msgRemoveText, null);
        final MessageEmbed messageEmbed = embedBuilder.build();
        replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed,
                BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS);
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:21,代碼來源:DefaultFeedbackStrategy.java

示例6: replyError

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
@Override
public void replyError(Config config, CommandEvent commandEvent, Throwable throwable, LocaleService localeService) {
    if (config != null && config.getReplyInDmWhenPossible()) {
        commandEvent.replyInDM(throwable.getMessage());
        commandEvent.reactError();
        handleOriginMessage(commandEvent);
    } else {
        commandEvent.reactError();
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(throwable.getMessage());
        final String msgRemoveText = localeService.getMessageFor(LocaleService.ERROR_KEEP_CHAT_CLEAN,
                localeService.getLocaleForUser(commandEvent.getAuthor()),
                String.valueOf(BotServerMain.timeToRemoveFeedbackInSeconds));
        embedBuilder.setFooter(msgRemoveText, null);
        final MessageEmbed messageEmbed = embedBuilder.build();
        replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed,
                BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS);
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:22,代碼來源:CleanUpMostFeedbackStrategy.java

示例7: createEmbedMessage

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
/**
 * Creates a simple embedded message
 */
public static MessageEmbed createEmbedMessage(Color colour, @Nullable String title, @Nullable String description)
{
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(colour);
    if(title != null)
        builder.setTitle(title);
    if(description != null)
        builder.setDescription(description);
    return builder.build();
}
 
開發者ID:thebrightspark,項目名稱:MDC-Discord-Bot,代碼行數:14,代碼來源:Util.java

示例8: 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

示例9: run

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
public Result run(String[] args, MessageReceivedEvent e) {
	EmbedBuilder eb = new EmbedBuilder();
	eb.addField("Invite me!", Config.getInvite(), false);
	eb.addField("Help server", Bot.helpServer, false);
	eb.addField("Website", Bot.website, true);
	eb = MessageUtils.addFooter(eb);
	return new Result(Outcome.SUCCESS, eb.build());
}
 
開發者ID:Tisawesomeness,項目名稱:Minecord,代碼行數:9,代碼來源:InviteCommand.java

示例10: run

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
public Result run(String[] args, MessageReceivedEvent e) throws Exception {
	
	//Check for argument length.
	if (args.length == 0) {
		return new Result(Outcome.WARNING, ":warning: You must specify an item!");
	}
	
	//Search through the item database
	Item item = Item.search(Item.values(), Item.prepareArgs(args));
	
	MessageUtils.log(
		"Item command executed" +
		"\nCommand: `" + e.getMessage().getContent() + "`" +
		"\nItem: `" + item + "`"
	);
	
	//If nothing is found
	if (item == null) {
		return new Result(Outcome.WARNING,
			":warning: That item does not exist! " +
			"\n" + "Did you spell it correctly?");
	}
	
	//Build message
	EmbedBuilder eb = item.getInfo();
	eb.setTitle(item.name);
	eb.setColor(Color.GREEN);
	eb.setFooter("See an error? Please report them at https://goo.gl/KWCxis", null);
	//eb = MessageUtils.addFooter(eb);
	
	return new Result(Outcome.SUCCESS, eb.build());
}
 
開發者ID:Tisawesomeness,項目名稱:Minecord,代碼行數:33,代碼來源:ItemCommand.java

示例11: getEmbed

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
public MessageEmbed getEmbed(Color color, String title, String url, CharSequence description, MessageEmbed.Field... fields) {
    EmbedBuilder e = new EmbedBuilder();
    e.setColor(color);
    for (MessageEmbed.Field field : fields) {
        e.addField(field);
    }
    e.setTitle(title, url);
    e.setDescription(description);
    return e.build();
}
 
開發者ID:NucleusPowered,項目名稱:Phonon,代碼行數:11,代碼來源:DiscordBot.java

示例12: createRaid

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
protected void createRaid(User user, GuildMessageReceivedEvent guildEvent, Config config,
                          ClockService clockService, PokemonRaidInfo pokemonRaidInfo,
                          LocalDateTime now, Raid raidToCreate, MessageChannel channel) {
    Raid createdRaid;
    if (raidToCreate.isExRaid()) {
        LOGGER.debug("Got an EX raid to create from gym integration, skipping: " + raidToCreate);
        return;
    }
    createdRaid = raidRepository.newRaid(user, raidToCreate, guildEvent.getGuild(), config,
            "(bot) !raid new " + raidToCreate.getPokemon().getName() + " " +
                    printTimeIfSameDay(raidToCreate.getEndOfRaid()) + " " + raidToCreate.getGym().getName());
    final Locale locale = config.getLocale();
    EmbedBuilder embedBuilder = new EmbedBuilder().setTitle(null, null);
    StringBuilder sb = new StringBuilder();
    sb.append(localeService.getMessageFor(LocaleService.NEW_RAID_CREATED,
            locale, createdRaid.toString(locale)));
    if (user != null && channel != null) {
        createGroupIfConfigSaysSo(user, guildEvent, config, clockService,
                pokemonRaidInfo, now, createdRaid, channel);
    } else {
        LOGGER.warn("Could not create group, as some input values were null!");
    }

    embedBuilder.setDescription(sb.toString());
    final MessageEmbed messageEmbed = embedBuilder.build();
    sendFeedbackThenCleanUp(createdRaid, channel, messageEmbed);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:28,代碼來源:GymHuntrRaidEventListener.java

示例13: generateListEmbed

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
private MessageEmbed generateListEmbed(CommandEvent e) {
    String path = "textchannel.list.";
    EmbedBuilder eb = new EmbedBuilder();
    eb.setDescription(Locale.getCommandsMessage((path + "header")).finish());
    eb.setColor(e.getGuild().getMember(e.getJDA().getSelfUser()).getColor());
    java.util.List<TextChannel> tcArray = mcb.getRelayChannels();
    tcArray.forEach((tc) -> {
        String gName = tc.getGuild().getName();
        String tcName = tc.getName();
        String str = Locale.getCommandsMessage(path + "guild_name").finish() + ": " + gName + "\n";
        str += Locale.getCommandsMessage(path + "channel_name").finish() + ": " + tcName;
        eb.addField("[" + tc + "]" + ": ", str, false);
    });
    return eb.build();
}
 
開發者ID:CyR1en,項目名稱:Minecordbot,代碼行數:16,代碼來源:TextChannelCmd.java

示例14: generate

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
private MessageEmbed generate(double tps) {
    EmbedBuilder eb = new EmbedBuilder();
    double lagPercentage = Math.round((1.0D - tps / 20.0D) * 100.0D);
    eb.addField("TPS:", "`" + new DecimalFormat("#.####").format(tps) + "`", true);
    eb.addField("Lag Percentage: ", lagPercentage + "%", true);
    eb.addField("Free RAM: ", Runtime.getRuntime().freeMemory() / 1024L / 1024L + "mb", true);
    eb.addField("Total Memory: ", Runtime.getRuntime().totalMemory() / 1024L / 1024L + "mb", true);
    eb.addField("Allocated Memory: ", Runtime.getRuntime().totalMemory() / 1024L / 1024L + "mb", true);
    eb.addBlankField(true);
    return eb.build();
}
 
開發者ID:CyR1en,項目名稱:Minecordbot,代碼行數:12,代碼來源:TpsCmd.java

示例15: run

import net.dv8tion.jda.core.EmbedBuilder; //導入方法依賴的package包/類
@Override
public Result run(String[] args, MessageReceivedEvent e) throws Exception {
	
	//Parse args
	if (args.length == 0) {
		return new Result(Outcome.WARNING, "Missing code argument.");
	}
	
	//Javascript engine with JDA, event and config variables.
	ScriptEngineManager factory = new ScriptEngineManager();
	ScriptEngine engine = factory.getEngineByName("JavaScript");
	engine.put("jda", e.getJDA());
	engine.put("config", Bot.config);
	engine.put("event", e);
	engine.put("guild", e.getGuild());
	engine.put("channel", e.getChannel());
	engine.put("user", e.getAuthor());
	
	//Extract code from message
	String code = "";
	for (String arg : args) {
		code += arg + " ";
	}
	code = code.substring(0, code.length() - 1);
	
	//Evaluate and print code
	Object output = engine.eval(code);
	if (output == null) {
		return new Result(Outcome.ERROR, ":x: Recieved null as output.");
	}
	
	EmbedBuilder eb = new EmbedBuilder();
	eb.addField("Input", "```js\n" + clean(code) + "\n```", false);
	eb.addField("Output", "```js\n" + clean(output.toString()) + "\n```", false);
	eb.setTimestamp(OffsetDateTime.now());
	User u = e.getAuthor();
	eb.setFooter("Sent by " + u.getName() + "#" + u.getDiscriminator() + " (" + u.getId() + ")", u.getAvatarUrl());
	
	return new Result(Outcome.SUCCESS, eb.build());
	
}
 
開發者ID:Tisawesomeness,項目名稱:Minecord,代碼行數:42,代碼來源:EvalCommand.java


注:本文中的net.dv8tion.jda.core.EmbedBuilder.build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。