本文整理匯總了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();
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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());
}