本文整理汇总了Java中net.dv8tion.jda.core.EmbedBuilder.setDescription方法的典型用法代码示例。如果您正苦于以下问题:Java EmbedBuilder.setDescription方法的具体用法?Java EmbedBuilder.setDescription怎么用?Java EmbedBuilder.setDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.EmbedBuilder
的用法示例。
在下文中一共展示了EmbedBuilder.setDescription方法的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();
}
}
示例2: 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);
}
}
示例3: 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());
}
}
示例4: 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();
}
示例5: send
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的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: sendConnectedMessage
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
private void sendConnectedMessage(TextChannel channelOne, TextChannel channelTwo) {
//GuildOne Message
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor("Connection established with " + channelTwo.getGuild().getName(), null, channelTwo.getGuild().getIconUrl());
embedBuilder.setDescription(":white_check_mark: Successfully created and connected portals.");
Message message1 = channelOne.sendMessage(embedBuilder.build()).complete();
channelOne.pinMessageById(message1.getId()).queue();
//GuildTwo Message
embedBuilder.setAuthor("Connection established with " + channelOne.getGuild().getName(), null, channelOne.getGuild().getIconUrl());
embedBuilder.setDescription(":white_check_mark: Successfully created and connected portals.");
Message message2 = channelTwo.sendMessage(embedBuilder.build()).complete();
channelTwo.pinMessageById(message2.getId()).queue();
}
示例7: generateEmbed
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public EmbedBuilder generateEmbed() {
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(Colors.COLOR_PRIMARY);
int i = 0;
StringBuilder description = new StringBuilder();
for(AudioTrack track : trackList) {
description.append(emotes[i]).append(" [").append(track.getInfo().title).append("](").append(track.getInfo().uri).append(")\n\n");
i++;
}
builder.setFooter("Type in your choose. <1-5> (After 15 seconds the request will be deleted)", null);
builder.setDescription(description.toString());
return builder;
}
示例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());
}
示例9: 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();
}
示例10: sendNowPlaying
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public void sendNowPlaying() {
isPlaying = true;
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("Playing:");
builder.setDescription(msg);
if (currentTrack instanceof YoutubeAudioTrack) {
String id = YouTubeHelper.extractVideoIdFromUrl(currentTrack.getInfo().uri);
trackImgUrl = String.format(Constant.youtubeThumbnailUrl, id);
} else if (currentTrack instanceof VimeoAudioTrack) {
trackImgUrl = Constant.vimeoIconUrl;
} else if (currentTrack instanceof TwitchStreamAudioTrack) {
trackImgUrl = Constant.twitchIconUrl;
} else if (currentTrack instanceof SoundCloudAudioTrack) {
trackImgUrl = Constant.soundcloudIconUrl;
} else if (currentTrack instanceof BandcampAudioTrack) {
trackImgUrl = Constant.bandcampIconUrl;
} else {
trackImgUrl = Constant.lambdaMusicIconUrl;
}
builder.setThumbnail(trackImgUrl);
builder.setFooter(server.getSelfMember().getNickname() != null ? server.getSelfMember().getNickname() : server.getSelfMember().getEffectiveName(), server.getIconUrl());
channel.getManager().setTopic("**Playing:** " + 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) {
}
}
示例11: run
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
Scanner messageIterator = new Scanner(args);
JDA shard = event.getJDA();
Member member = event.getMember();
User user = event.getAuthor();
Message message = event.getMessage();
TextChannel channel = event.getChannel();
Guild guild = event.getGuild();
if (!member.hasPermission(Permission.KICK_MEMBERS)) {
DiscordUtils.failMessage(bot, message, "You don't have enough permissions to execute this command!");
return false;
}
if (!messageIterator.hasNext(DiscordUtils.USER_MENTION_PATTERN)) {
return true;
} else {
// advance the scanner one step to get rid of user mention
messageIterator.next();
}
User warnUser = message.getMentionedUsers().get(0);
Member warnMember = guild.getMember(warnUser);
if (user.getId().equals(warnUser.getId())) {
DiscordUtils.failMessage(bot, message, "You can't warn yourself, dummy!");
return false;
}
String reason = TextUtils.seekScannerToEnd(messageIterator);
reason = reason.equals("") ? "No reason specified" : reason;
Date now = new Date();
EmbedBuilder embed = new EmbedBuilder();
embed.setTitle("Warned in " + guild.getName());
embed.setColor(new Color(0x4286F4));
embed.setDescription("You were warned in " + guild.getName());
embed.addField("Reason:", reason, false);
embed.setFooter("Warned by " + DiscordUtils.getUserTagAndId(user), null);
embed.setTimestamp(now.toInstant());
try {
DiscordUtils.sendDM(warnUser, embed.build());
} catch (Exception e) {
DiscordUtils.sendMessage(channel, "Could not send a warning to the specified user via private message!");
}
DiscordUtils.successReact(bot, message);
DSLContext database = bot.getDatabase();
WarnlistRecord record = database.insertInto(Tables.WARNLIST,
Tables.WARNLIST.USERID,
Tables.WARNLIST.MODERATORUSERID,
Tables.WARNLIST.GUILDID,
Tables.WARNLIST.WARNTIME,
Tables.WARNLIST.REASON)
.values(warnUser.getId(),
user.getId(),
guild.getId(),
now.getTime() / 1000,
reason)
.returning(Tables.WARNLIST.ID)
.fetchOne();
DiscordUtils.createModLogEntry(bot, shard, message, warnMember, reason, "warn", record.getId(), null, false);
DiscordUtils.sendMessage(channel, "Warned " + DiscordUtils.getUserTagAndId(warnUser));
return false;
}
示例12: run
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public static void run(MessageReceivedEvent event, String arguments, boolean respondToBots) {
if (event.getAuthor().isBot() != respondToBots) {
return;
}
if (!Lib.WL.contains(event.getAuthor().getIdLong())) {
return;
}
String[] args = arguments.split("\\s", 4);
String[] a = arguments.split("\\s", 3);
if (args.length == 2) {
if (args[1].equalsIgnoreCase("print")) {
EmbedBuilder eb = new EmbedBuilder();
eb.setColor(new Color(47, 166, 222));
List<Message> votes = Voteutils.getVotes(event);
eb.setDescription(
votes.stream().map(Message::getContent).collect(Collectors.joining("\n"))
);
event.getChannel().sendMessage(eb.build()).queue();
return;
} else {
event.getChannel().sendMessage(new MessageBuilder().appendCodeBlock(
"public void returnError(String text) {" +
" try {" +
" throw new IllegalArgumentException(text);" +
" } catch(IllegalArgumentException ex) {" +
" ex.printStackTrace();" +
" }","Java").build()).queue();
}
}
else if (args.length >= 3) {
switch (args[1]) {
case "close" :
Voteutils.deleteVote(Integer.parseInt(args[2]), event, Boolean.valueOf(args[3]));
break;
case "state" :
Useless.shards.get(0).getGuildById(Lib.LOG_GUILD).getTextChannelsByName("votes", true).get(0).sendMessage(Voteutils.getResult(Integer.parseInt(args[2]), event)).queue();
break;
case "create" :
Voteutils.createVote(a[2]);
}
}
else {
event.getChannel().sendMessage(new MessageBuilder().appendCodeBlock(
"public void returnError(String text) {" +
" try {" +
" throw new IllegalArgumentException(text);" +
" } catch(IllegalArgumentException ex) {" +
" ex.printStackTrace();" +
" }","Java").build()).queue();
}
}
示例13: end
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的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();
}
}
示例14: respond
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public void respond(CommandEvent event, String message, ResponseLevel level) {
EmbedBuilder eb = new EmbedBuilder();
eb.setDescription(message);
respond(event, embedMessage(event, eb.build(), level));
}
示例15: attemptSignUpFromPlusCommand
import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
private void attemptSignUpFromPlusCommand(GuildMessageReceivedEvent guildMessageReceivedEvent, String[] splitArguments) {
final String numberOfPeopleArgument = splitArguments[0];
final String etaArgument = splitArguments[1];
final String[] gymArgument = ArrayUtils.removeAll(splitArguments, 0, 1);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Trying to add " + numberOfPeopleArgument + " to raid, ETA " + etaArgument + " to gym " +
StringUtils.join(gymArgument, " "));
}
final String guild = guildMessageReceivedEvent.getGuild().getName().trim().toLowerCase();
final Config configForServer = serverConfigRepository.getConfigForServer(guild);
final User user = guildMessageReceivedEvent.getAuthor();
String message;
try {
message = raidRepository.executeSignUpCommand(configForServer, user,
localeService.getLocaleForUser(user),
splitArguments, "signup");
guildMessageReceivedEvent.getMessage().addReaction(Emotes.OK).queue();
ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
} catch (Throwable t) {
LOGGER.debug("Signup plus command failed: " + t.getMessage());
message = t.getMessage() + "\n\n" +
"Syntax: *+1 09:45 Solna Platform*";
guildMessageReceivedEvent.getMessage().addReaction(Emotes.ERROR).queue();
ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
}
if (!StringUtils.isEmpty(message)) {
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(user), "15");
embedBuilder.setFooter(msgRemoveText, null);
guildMessageReceivedEvent.getMessage().getChannel().sendMessage(embedBuilder.build())
.queue(msg -> {
msg.delete().queueAfter(15, TimeUnit.SECONDS); // Clean up feedback after x seconds
}
);
LOGGER.debug("Added signup.");
}
}