本文整理汇总了Java中net.dv8tion.jda.core.MessageBuilder.setEmbed方法的典型用法代码示例。如果您正苦于以下问题:Java MessageBuilder.setEmbed方法的具体用法?Java MessageBuilder.setEmbed怎么用?Java MessageBuilder.setEmbed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.MessageBuilder
的用法示例。
在下文中一共展示了MessageBuilder.setEmbed方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public Message render(Color color, Instant now)
{
MessageBuilder mb = new MessageBuilder();
boolean close = now.plusSeconds(6).isAfter(end);
mb.append(Constants.YAY).append(close ? " **G I V E A W A Y** " : " **GIVEAWAY** ").append(Constants.YAY);
EmbedBuilder eb = new EmbedBuilder();
if(close)
eb.setColor(Color.RED);
else if(color==null)
eb.setColor(Constants.BLURPLE);
else
eb.setColor(color);
eb.setFooter((winners==1 ? "" : winners+" Winners | ")+"Ends at",null);
eb.setTimestamp(end);
eb.setDescription("React with "+Constants.TADA+" to enter!\nTime remaining: "+FormatUtil.secondsToTime(now.until(end, ChronoUnit.SECONDS)));
if(prize!=null)
eb.setAuthor(prize, null, null);
if(close)
eb.setTitle("Last chance to enter!!!", null);
mb.setEmbed(eb.build());
return mb.build();
}
示例2: execute
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
EmbedBuilder eb = new EmbedBuilder();
MessageBuilder mb = new MessageBuilder();
mb.append(Constants.YAY+" All about **GiveawayBot** "+Constants.YAY);
//eb.setThumbnail("http://i.imgur.com/sCEbmKa.png");
eb.setTitle("Hold giveaways quickly and easily!");
eb.setDescription("Hello! I'm **GiveawayBot**, and I'm here to make it as easy as possible to hold "
+ "giveaways on your Discord server! I was created by [**jagrosh**#4824](http://jagrosh.com) "
+ "(<@113156185389092864>) using the [JDA]("+JDAInfo.GITHUB+") library ("+JDAInfo.VERSION+") and "
+ "[JDA-Utilities]("+JDAUtilitiesInfo.GITHUB+") ("+JDAUtilitiesInfo.VERSION+"). Check out my "
+ "commands by typing `!ghelp`, and checkout my website at **http://giveawaybot.party**.");
eb.addField("\uD83D\uDCCA Stats", bot.getShards().stream().mapToInt(jda -> jda.getGuilds().size()).sum()+" servers\n"+bot.getShards().size()+" shards\n"
+bot.getShards().stream().mapToInt(jda -> jda.getUsers().size()).sum()+" users", true);
eb.addField("\uD83C\uDF89 Giveaways", bot.getGiveaways().size()+" right now!", true);
eb.addField("\uD83C\uDF10 Links", "[Website]("+Constants.WEBSITE+")\n[Invite]("+Constants.INVITE+")\n[Support](https://discord.gg/0p9LSGoRLu6Pet0k)", true);
eb.setFooter("Last restart", null);
eb.setTimestamp(Constants.START);
eb.setColor(Constants.BLURPLE);
mb.setEmbed(eb.build());
event.getChannel().sendMessage(mb.build()).queue();
}
示例3: createMessage
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public static Message createMessage(String title, String description, boolean success){
MessageBuilder embed = new MessageBuilder();
Color color;
if(success){
color = Color.green;
}else{
color = Color.red;
}
if(title != null && !title.isEmpty()){
embed.append(String.format("`%s`", title.replaceAll("`", "")));
}
if(description != null && !description.isEmpty()){
embed.setEmbed(new EmbedBuilder().setDescription(description.replaceAll("`", "")).setColor(color).build());
}
return embed.build();
}
示例4: onCommand
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
@Override
public boolean onCommand(Message message, String[] args) {
User user = MentionableUtil.getUser(message, args);
if (user == null) {
return sendErrorMessage(message, "You must mention a use you want to use the interaction for.");
}
message.getChannel().sendTyping().queue();
int imageIndex = RandomUtil.getInteger(getInteractionImages().size());
MessageBuilder messageBuilder = new MessageBuilder();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder
.setImage("attachment://" + getClass().getSimpleName() + "-" + imageIndex + ".gif")
.setDescription(buildMessage(message, user))
.setColor(getInteractionColor());
messageBuilder.setEmbed(embedBuilder.build());
try {
InputStream stream = new URL(getInteractionImages().get(imageIndex)).openStream();
message.getChannel().sendFile(stream, getClass().getSimpleName() + "-" + imageIndex + ".gif", messageBuilder.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
示例5: send
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
private void send(GenericGuildMemberEvent event, MessageChannel channel, String message, boolean rich) {
if (channel == null) {
return;
}
// process message
MapPlaceholderResolver resolver = new MapPlaceholderResolver();
resolver.put("user", event instanceof GuildMemberLeaveEvent
? event.getUser().getName() : event.getUser().getAsMention());
resolver.put("guild", event.getGuild().getName());
message = placeholderHelper.replacePlaceholders(message, resolver);
if (message.contains("#")) {
for (TextChannel textChannel : event.getGuild().getTextChannels()) {
message = message.replace("#" + textChannel.getName(), textChannel.getAsMention());
}
}
MessageBuilder builder = new MessageBuilder();
if (rich) {
Guild guild = event.getGuild();
EmbedBuilder embedBuilder = messageService.getBaseEmbed();
embedBuilder.setAuthor(guild.getName(), null, guild.getIconUrl());
embedBuilder.setDescription(message);
builder.setEmbed(embedBuilder.build());
} else {
builder.append(message);
}
messageService.sendMessageSilent(channel::sendMessage, builder.build());
}
示例6: renderPage
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
private Message renderPage(int pageNum)
{
MessageBuilder mbuilder = new MessageBuilder();
EmbedBuilder ebuilder = new EmbedBuilder();
ebuilder.setImage(urls.get(pageNum-1));
ebuilder.setColor(color.apply(pageNum, urls.size()));
ebuilder.setDescription(description.apply(pageNum, urls.size()));
if(showPageNumbers)
ebuilder.setFooter("Image "+pageNum+"/"+urls.size(), null);
mbuilder.setEmbed(ebuilder.build());
if(text!=null)
mbuilder.append(text.apply(pageNum, urls.size()));
return mbuilder.build();
}
示例7: getMessage
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
private Message getMessage()
{
MessageBuilder mbuilder = new MessageBuilder();
if(text!=null)
mbuilder.append(text);
if(description!=null)
mbuilder.setEmbed(new EmbedBuilder().setColor(color).setDescription(description).build());
return mbuilder.build();
}
示例8: renderPage
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
private Message renderPage(int pageNum)
{
MessageBuilder mbuilder = new MessageBuilder();
EmbedBuilder ebuilder = new EmbedBuilder();
int start = (pageNum-1)*itemsPerPage;
int end = strings.size() < pageNum*itemsPerPage ? strings.size() : pageNum*itemsPerPage;
switch(columns)
{
case 1:
StringBuilder sbuilder = new StringBuilder();
for(int i=start; i<end; i++)
sbuilder.append("\n").append(numberItems ? "`"+(i+1)+".` " : "").append(strings.get(i));
ebuilder.setDescription(sbuilder.toString());
break;
default:
int per = (int)Math.ceil((double)(end-start)/columns);
for(int k=0; k<columns; k++)
{
StringBuilder strbuilder = new StringBuilder();
for(int i=start+k*per; i<end && i<start+(k+1)*per; i++)
strbuilder.append("\n").append(numberItems ? (i+1)+". " : "").append(strings.get(i));
ebuilder.addField("", strbuilder.toString(), true);
}
}
ebuilder.setColor(color.apply(pageNum, pages));
if(showPageNumbers)
ebuilder.setFooter("Page "+pageNum+"/"+pages, null);
mbuilder.setEmbed(ebuilder.build());
if(text!=null)
mbuilder.append(text.apply(pageNum, pages));
return mbuilder.build();
}
示例9: getMessage
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
private Message getMessage()
{
MessageBuilder mbuilder = new MessageBuilder();
if(text!=null)
mbuilder.append(text);
StringBuilder sb = new StringBuilder();
for(int i=0; i<choices.size(); i++)
sb.append("\n").append(getEmoji(i+1)).append(" ").append(choices.get(i));
mbuilder.setEmbed(new EmbedBuilder().setColor(color).setDescription(description==null ? sb.toString() : description+sb.toString()).build());
return mbuilder.build();
}
示例10: end
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public void end(RestJDA restJDA)
{
MessageBuilder mb = new MessageBuilder();
mb.append(Constants.YAY).append(" **GIVEAWAY ENDED** ").append(Constants.YAY);
EmbedBuilder eb = new EmbedBuilder();
eb.setColor(new Color(1));
eb.setFooter((winners==1 ? "" : winners+" Winners | ")+"Ended at",null);
eb.setTimestamp(end);
if(prize!=null)
eb.setAuthor(prize, null, null);
try {
List<Long> ids = restJDA.getReactionUsers(Long.toString(channelId), Long.toString(messageId), MiscUtil.encodeUTF8(Constants.TADA))
.cache(true).stream().collect(Collectors.toList());
List<Long> wins = selectWinners(ids, winners);
String toSend;
if(wins.isEmpty())
{
eb.setDescription("Could not determine a winner!");
toSend = "A winner could not be determined!";
}
else if(wins.size()==1)
{
eb.setDescription("Winner: <@"+wins.get(0)+">");
toSend = "Congratulations <@"+wins.get(0)+">! You won"+(prize==null ? "" : " the **"+prize+"**")+"!";
}
else
{
eb.setDescription("Winners:");
wins.forEach(w -> eb.appendDescription("\n").appendDescription("<@"+w+">"));
toSend = "Congratulations <@"+wins.get(0)+">";
for(int i=1; i<wins.size(); i++)
toSend+=", <@"+wins.get(i)+">";
toSend+="! You won"+(prize==null ? "" : " the **"+prize+"**")+"!";
}
mb.setEmbed(eb.build());
restJDA.editMessage(channelId, messageId, mb.build()).queue();
restJDA.sendMessage(channelId, toSend).queue();
} catch(Exception e) {
eb.setDescription("Could not determine a winner!");
mb.setEmbed(eb.build());
restJDA.editMessage(channelId, messageId, mb.build()).queue();
restJDA.sendMessage(channelId, "A winner could not be determined!").queue();
}
}
示例11: createEmbed
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public Message createEmbed(Color color, String title, String desc) {
MessageBuilder mb = new MessageBuilder();
mb.setEmbed(
new EmbedBuilder().setColor(color).setTitle(title, null).setDescription(desc).build());
return mb.build();
}
示例12: execute
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
@Override
public boolean execute(User user, TextChannel channel, String command, List<String> parameters, Message message) throws Exception
{
if (parameters.size() < 1)
{
channel.sendMessage("You need to specify a series of time ranges to create a napchart. For example: `" + NapBot.CONFIGURATION.messagePrefix + "create 03:00-05:00 08:00-08:20 14:00-14:20 21:00-23:00`").complete();
return true;
}
PayloadInner payloadInner = new PayloadInner();
for (String parameter : parameters)
{
Matcher matcher = this.TIMESTAMP_PATTERN.matcher(parameter);
if (matcher.matches())
{
int startH = Integer.parseInt(matcher.group(2));
int startM = Integer.parseInt(matcher.group(3));
int endH = Integer.parseInt(matcher.group(5));
int endM = Integer.parseInt(matcher.group(6));
payloadInner.addSleepBlock(startH, startM, endH, endM);
}
else
{
channel.sendMessage("`" + parameter + "` doesn't seem to be a valid time range.\n\nYou need to specify a series of time ranges to create a napchart. For example: `" + NapBot.CONFIGURATION.messagePrefix + "create 03:00-05:00 08:00-08:20 14:00-14:20 21:00-23:00`").complete();
return true;
}
}
payloadInner.finalize();
Payload payload = new Payload(payloadInner);
String napchartID = Communicator.basicJsonMessage("Generate napchart", "https://napchart.com/api/create", payload, PayloadResponse.class, false).id;
try
{
NapchartHandler.getNapchart(napchartID);
}
catch (IOException e)
{
// yay.
e.printStackTrace();
}
MessageBuilder b = new MessageBuilder();
MessageEmbedImpl embedimpl = new MessageEmbedImpl();
embedimpl.setTitle("https://napchart.com/" + napchartID);
embedimpl.setUrl("https://napchart.com/" + napchartID);
embedimpl.setImage(new ImageInfo(NapBot.CONFIGURATION.napchartUrlPrefix + napchartID + "?" + NapBot.RESYNC_ID, null, 560, 560));
embedimpl.setFields(new ArrayList<MessageEmbed.Field>());
b.setEmbed(embedimpl);
channel.sendMessage(b.build()).complete();
return true;
}
示例13: onGuildMemberJoin
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public void onGuildMemberJoin(GuildMemberJoinEvent memberJoinEvent){
try{
if(IBBot.isInDevOnlyMode()){
return;
}
TextChannel joinLeave = null;
for(TextChannel tc : memberJoinEvent.getGuild().getTextChannels()) {
if (tc.getIdLong() == 270485260960006144L) {
joinLeave = tc;
}
}
if(joinLeave == null) {
return;
}
EmbedBuilder ebJoinMessage = new EmbedBuilder();
MessageBuilder message = new MessageBuilder();
ebJoinMessage.setColor(Color.white);
ebJoinMessage.setAuthor("IB-Bot", Configuration.getBotGithubLink(), null);
ebJoinMessage.setDescription("**Hello and welcome to the official /r/IBO Discord Server " + memberJoinEvent.getMember().getAsMention() + "!!** " +
"\n");
ebJoinMessage.addField("How To Access The Server:", "In order for you to gain full access to all common channels, as well as those corresponding to your subjects, you must do the following: " +
"\n " +
"\n 1) Read the rules! " +
"\n 2) Add the year your final exams will be in: " +
"\n *Please join new roles in the #role-spam channel!*" +
"\n```Nov 2019 -> " + Configuration.getBotPrefix() + "join Nov-2019" +
"\nMay 2019 -> " + Configuration.getBotPrefix() + "join May-2019 " +
"\nNov 2018 -> " + Configuration.getBotPrefix() + "Join Nov-2018" +
"\nMay 2018 -> " + Configuration.getBotPrefix() + "Join May-2018" +
"\n " +
"\nAlumni -> " + Configuration.getBotPrefix() + "Join Alumni" +
"\nPre IB student -> " + Configuration.getBotPrefix() + "Join Pre-IB" +
"\nNot an IB student? -> " + Configuration.getBotPrefix() + "Join Not-IB``` " +
"\n 3) Verify Yourself; Type `" + Configuration.getBotPrefix() + "verify` in this channel, to get full access to the server.", false);
ebJoinMessage.addField("Joining Subjects:", "To see the channels where you can discuss individual subjects, just type: " +
"\n `" + Configuration.getBotPrefix() + "[SubjectName]`" +
"\n " +
"\n You can see a full list of all subjects by typing: " +
"\n `" + Configuration.getBotPrefix() + "SubjectList`", false);
ebJoinMessage.addField("Further Help:", "For more commands use: " +
"\n `" + Configuration.getBotPrefix() + "Help`", false);
File welcomeGIF = new File("WelcomeGIF.gif");
message.setEmbed(ebJoinMessage.build());
joinLeave.sendFile(welcomeGIF, message.build()).queue();
}catch(Exception e){
e.printStackTrace();
}
}