本文整理汇总了Java中net.dv8tion.jda.core.EmbedBuilder类的典型用法代码示例。如果您正苦于以下问题:Java EmbedBuilder类的具体用法?Java EmbedBuilder怎么用?Java EmbedBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EmbedBuilder类属于net.dv8tion.jda.core包,在下文中一共展示了EmbedBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
@Override
public void handle(Message message, Event event, String[] args) throws Throwable {
Language l = kyoko.getI18n().getLanguage(message.getGuild());
EmbedBuilder builder = kyoko.getAbstractEmbedBuilder().getNormalBuilder()
.setAuthor(kyoko.getI18n().get(l, "stats.title"), Constants.SITE_URL, kyoko.getJda().getSelfUser().getAvatarUrl())
.addField(kyoko.getI18n().get(l, "stats.field.library"), "JDA " + JDAInfo.VERSION, true)
.addField(kyoko.getI18n().get(l, "stats.field.shard"), kyoko.getShardInfo(), true)
.addField(kyoko.getI18n().get(l, "stats.field.version"), Constants.VERSION, true)
.addField(kyoko.getI18n().get(l, "stats.field.uptime"), StringUtil.prettyPeriod(rb.getUptime()), true)
.addField(kyoko.getI18n().get(l, "stats.field.users"), Integer.toString(kyoko.getJda().getUsers().size()), true)
.addField(kyoko.getI18n().get(l, "stats.field.servers"), Integer.toString(kyoko.getJda().getGuilds().size()), true)
.addField(kyoko.getI18n().get(l, "stats.field.textchans"), Integer.toString(kyoko.getJda().getTextChannels().size()), true)
.addField(kyoko.getI18n().get(l, "stats.field.voicechans"), Integer.toString(kyoko.getJda().getVoiceChannels().size()), true)
.addField(kyoko.getI18n().get(l, "stats.field.cmdsran"), Long.toString(kyoko.getCommandManager().getCommandRunCount()), true)
.addField(kyoko.getI18n().get(l, "stats.field.github"), Constants.GITHUB_URL_MD, true)
.addField(kyoko.getI18n().get(l, "stats.field.website"), Constants.SITE_URL_MD, true)
.addField(kyoko.getI18n().get(l, "stats.field.donate"), "*soon*", true)
.addField(kyoko.getI18n().get(l, "stats.field.authors"), kyoko.getI18n().get(l, "stats.authors"), true);
message.getChannel().sendMessage(builder.build()).queue();
}
示例2: run
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
@Override
public void run() {
Roles.TWITTER.getRole().getManager().setMentionable(true).queue();
EmbedBuilder builder = new EmbedBuilder()
.setThumbnail(status.getUser().getBiggerProfileImageURL())
.setTitle("@" + status.getUser().getScreenName() + " has just tweeted", "https://twitter.com/" + status.getUser().getScreenName() + "/status/" + status.getId())
.setDescription(status.getText())
.setColor(new Color(0, 172, 237));
if (status.getInReplyToScreenName() != null) {
builder.addField("In reply to..", "[In reply to this @" + status.getInReplyToScreenName() + "'s tweet]" +
"(https://twitter.com/" + status.getInReplyToScreenName() + "/status/" + status.getInReplyToStatusId() + ")", false);
}
if (status.getUser().getId() == twitterCentre.getHappyid()) {
Channels.TWITTER.getChannel().sendMessage(Roles.TWITTER.getRole().getAsMention()).queue();
Channels.TWITTER.getChannel().sendMessage(builder.build()).queue();
}
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Roles.TWITTER.getRole().getManager().setMentionable(false).queue();
}
}
示例3: onMessageReceived
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().equals(RubiconBot.getJDA().getSelfUser()))
if (event.isFromType(ChannelType.PRIVATE)) return;
if (RubiconBot.getMySQL().isBlacklisted(event.getTextChannel())) return;
MusicManager.handleTrackChoose(event);
super.onMessageReceived(event);
ParsedCommandInvocation commandInvocation = parse(event.getMessage());
//Send typing because it's useless
if (commandInvocation != null && !event.getAuthor().isBot() && !event.getAuthor().isFake() && !event.isWebhookMessage()) {
if (event.getAuthor().getId().equals("343825218718007296")) {
event.getTextChannel().sendMessage(new EmbedBuilder()
.setTitle(":rotating_light: __**ERROR**__ :rotating_light:")
.setDescription("403 WRONG GUY")
.setColor(Color.RED)
.build()).queue();
return;
}
if (GlobalBlacklist.isOnBlacklist(event.getAuthor())) {
event.getTextChannel().sendMessage(EmbedUtil.message(EmbedUtil.error("Blacklisted", "You are on the RubiconBot blacklist! ;)"))).queue(msg -> msg.delete().queueAfter(20, TimeUnit.SECONDS));
return;
}
call(commandInvocation);
}
}
示例4: sendTeamUserEmbed
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
public static void sendTeamUserEmbed(CommandEvent event, BeamTeamUser member) {
JDAManager.sendMessage(event,
new EmbedBuilder().setTitle(member.username, String.format("https://beam.pro/%s", member.username))
.setThumbnail(String.format("https://beam.pro/api/v1/users/%d/avatar?_=%d", member.id,
new Random().nextInt()))
.setDescription(StringUtils.isBlank(member.bio) ? "No bio" : member.bio)
.addField("Followers", Integer.toString(member.channel.numFollowers), true)
.addField("Views", Integer.toString(member.channel.viewersTotal), true)
.addField("Partnered", member.channel.partnered ? "Yes" : "No", true)
.addField("Primary Team", BeamManager.getTeam(member.primaryTeam).name, true)
.addField("Joined Beam", member.createdAt.toString(), true)
.addField("Member Since", member.teamMembership.createdAt.toString(), true)
.setImage(String.format("https://thumbs.beam.pro/channel/%d.small.jpg?_=%d", member.channel.id,
new Random().nextInt()))
.setFooter("Beam.pro", BEAM_LOGO_URL).setTimestamp(Instant.now()).setColor(COLOR).build());
}
示例5: extendHelp
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
public void extendHelp(MessageReceivedEvent event, BotContext context, EmbedBuilder embedBuilder) {
// Пользовательские команды
if (event.getChannelType().isGuild() && context.getConfig() != null) {
List<CustomCommand> commands = commandRepository.findByConfig(context.getConfig());
if (CollectionUtils.isNotEmpty(commands)) {
StringBuilder list = new StringBuilder();
commands.forEach(e -> {
if (list.length() > 0) {
list.append(", ");
}
list.append('`').append(context.getConfig().getPrefix()).append(e.getKey()).append('`');
});
if (list.length() > 0) {
embedBuilder.addField(messageService.getMessage(GROUP_KEY) + ":",
list.toString(), false);
}
}
}
}
示例6: reply
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
@Override
public void reply(Config config, CommandEvent commandEvent, String message, int numberOfSecondsBeforeRemove,
LocaleService localeService) {
// Give the caller some slack but not much
Validate.isTrue(numberOfSecondsBeforeRemove > 5);
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(message);
commandEvent.reactSuccess();
} 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);
sendMessageThenDeleteAfterXSeconds(commandEvent, embedBuilder.build(),
numberOfSecondsBeforeRemove, TimeUnit.SECONDS);
}
}
示例7: doCommand
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
@Override
public boolean doCommand(MessageReceivedEvent message, BotContext context, String query) {
if (!discordService.isSuperUser(message.getAuthor()) || StringUtils.isEmpty(query)) {
return false;
}
message.getChannel().sendTyping();
String script = CommonUtils.unwrapCode(query);
try {
Object result = getShell(message).evaluate(script);
if (result != null) {
messageService.sendMessageSilent(message.getChannel()::sendMessage,
"```groovy\n" + String.valueOf(result) + "```");
}
} catch (Exception e) {
String errorText = String.format("\n`%s`\n\nStack trace:```javascript\n%s", e.getMessage(), ExceptionUtils.getStackTrace(e));
EmbedBuilder builder = messageService.getBaseEmbed();
builder.setTitle(e.getClass().getName());
builder.setColor(Color.RED);
builder.setDescription(CommonUtils.trimTo(errorText, 2045) + "```");
messageService.sendMessageSilent(message.getChannel()::sendMessage, builder.build());
return fail(message);
}
return ok(message);
}
示例8: handle
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
String[] split = event.getMessage().getContent().split(" ");
String prefix = plugin.getBot().getGuildSettings(event.getGuild()).getSetting("PREFIX");
if (prefix == null ) {
prefix = "!";
}
String value = split[0].substring(prefix.length()).toLowerCase();
String result = plugin.getServerCommands(event.getGuild()).get(value);
if (result != null) {
if (result.contains(".png") || result.contains(".jpg") || result.contains(".gif")) {
EmbedBuilder eb = new EmbedBuilder();
eb.setImage(result);
eb.setTitle(value);
eb.build();
event.getChannel().sendMessage(eb.build()).queue();
} else {
event.getChannel().sendMessage(result).queue();
}
}
}
示例9: 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);
}
}
示例10: 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();
} else {
commandEvent.reactSuccess();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(message);
commandEvent.reply(embedBuilder.build());
}
}
示例11: setPhoto
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
private void setPhoto(EmbedBuilder builder, CallbackMessage<CallbackWallPost> message, Photo photo, boolean showText) {
String url = String.format(PHOTO_URL,
Math.abs(message.getGroupId()),
message.getObject().getId(),
Math.abs(photo.getOwnerId()),
photo.getId());
if (showText) {
setText(builder, photo.getText(), url);
}
builder.setImage(coalesce(photo.getPhoto2560(),
photo.getPhoto1280(),
photo.getPhoto807(),
photo.getPhoto604(),
photo.getPhoto130(),
photo.getPhoto75()));
if (photo.getDate() != null) {
builder.setTimestamp(new Date(((long) photo.getDate()) * 1000).toInstant());
}
}
示例12: onGuildMemberNickChange
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
@Override
public void onGuildMemberNickChange(GuildMemberNickChangeEvent e) {
if (!Bot.isReady)
return;
GuildObject g = GuildObject.guildMap.get(e.getGuild().getId());
EmbedBuilder em = new EmbedBuilder();
em.setColor(Color.CYAN)
.setTimestamp(Instant.now());
if (!g.getSpecialChannels().getLog().equals("")) {
if (e.getPrevNick() != null && e.getNewNick() != null) {
em.setDescription("**" + e.getPrevNick() + "** to **" + e.getNewNick() + "**");
em.setAuthor(e.getMember().getUser().getName() + " changed their nickname",
null, e.getMember().getUser().getAvatarUrl());
} else if (e.getPrevNick() != null && e.getNewNick() == null) {
em.setDescription("**" + e.getPrevNick() + "** to **" + e.getMember().getUser().getName() + "**");
em.setAuthor(e.getMember().getUser().getName() + " removed their nickname",
null, e.getMember().getUser().getAvatarUrl());
} else {
em.setDescription("**" + e.getMember().getUser().getName() + "** to **" + e.getNewNick() + "**");
em.setAuthor(e.getMember().getUser().getName() + " added a nickname", null,
e.getMember().getUser().getAvatarUrl());
}
MessageUtils.sendMessage(g.getSpecialChannels().getLog(), em.build());
}
}
示例13: onCommand
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
/**
* The method to handle the command.
*
* @param jda The JDA instance.
* @param message The message sent.
*/
@RegisterCommand(aliases = "rewards",
usage = "{prefix}rewards",
description = "Displays the possible rewards from levelling up.")
public void onCommand(JDA jda, Message message) {
EmbedBuilder embed = new EmbedBuilder();
embed.setAuthor("Rewards", null, jda.getSelfUser().getEffectiveAvatarUrl());
embed.setColor(Color.decode(Config.EMBED_COLOUR));
for (int level : AutoRole.roles.keySet()) {
String role = AutoRole.roles.get(level).get("name").toString();
embed.addField(role, "Rewarded at level " + level + ".", true);
}
message.getChannel().sendMessage(embed.build()).complete();
}
示例14: Trivia
import net.dv8tion.jda.core.EmbedBuilder; //导入依赖的package包/类
public Trivia(TextChannel channel, TLongSet players, OpenTriviaDatabase.Question question) {
super(channel, players, question.correctAnswer, (question.incorrectAnswers.size() + 1) / 2);
List<String> options = new ArrayList<>(question.incorrectAnswers);
options.add(question.correctAnswer);
int triesLeft = options.size()/2;
totalOptions = options.size();
correctOptionIndex = options.indexOf(question.correctAnswer);
Collections.shuffle(options);
int[] idx = {1};
channel.sendMessage(new EmbedBuilder()
.setDescription("**" + question.question + "**")
.addField("Options", options.stream().map(o->idx[0]++ + " - " + o).collect(Collectors.joining("**\n**", "**", "**")), false)
.addField("Difficulty", question.difficulty, true)
.addField("Category", question.category, true)
.setFooter(triesLeft + " tries left | Answer with the option number", null)
.build()
).queue();
}
示例15: 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);
}
}