本文整理汇总了Java中net.dv8tion.jda.core.MessageBuilder.append方法的典型用法代码示例。如果您正苦于以下问题:Java MessageBuilder.append方法的具体用法?Java MessageBuilder.append怎么用?Java MessageBuilder.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.MessageBuilder
的用法示例。
在下文中一共展示了MessageBuilder.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: execute
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
@Override
public void execute(MessageReceivedEvent event, String[] args) {
if (plugin.getBot().getGuildSettings(event.getGuild()).getGuildName() == null || plugin.getBot().getGuildSettings(event.getGuild()).getRegionName() == null) {
event.getChannel().sendMessage("You can't run this command. A server administrator needs to configure the bot first. Ask him to use !setup.").queue();
return;
}
List<User> mentionedUsers = event.getMessage().getMentionedUsers();
List<String> charactersList;
MessageBuilder builder = new MessageBuilder();
if (!mentionedUsers.isEmpty()) {
builder.append(mentionedUsers.get(0).getName() + " WoW characters in the Guild ");
charactersList = plugin.getUserCharactersInGuild(mentionedUsers.get(0), event.getGuild());
} else {
builder.append("Your WoW characters in the Guild ");
charactersList = plugin.getUserCharactersInGuild(event.getAuthor(),event.getGuild());
}
builder.append(plugin.getBot().getGuildSettings(event.getGuild()).getGuildName());
builder.append("\n");
charactersList.forEach((c) -> builder.append(c + "\n"));
event.getAuthor().openPrivateChannel().queue((c) -> c.sendMessage(builder.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: appendUsersRawAndInfo
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public static String appendUsersRawAndInfo(List<Player> players) {
MessageBuilder mb = new MessageBuilder();
for (int i = 0; i < players.size(); i++) {
Player p = players.get(i);
mb.append(p.getUser());
if (!p.isAlive()) {
mb.append(" dead");
}
if (p.isChancellor()) {
mb.append(" chancellor");
}
if (p.isPresident()) {
mb.append(" president");
}
if (p.isPreviousChancellor()) {
mb.append(" previousChancellor");
}
if (p.isPreviousPresident()) {
mb.append(" previousPresident");
}
if (i < players.size() - 1) {
mb.append(", ");
}
}
return mb.build().getRawContent();
}
示例5: onGuildMessageReceived
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
// Do not reply to self
if (e.getAuthor().getId().equals(e.getJDA().getSelfUser().getId())) {
return;
}
String[] args = e.getMessage().getRawContent().split(" ");
// Reply only if @botname is args[0] and args.length == 1
if (args[0].equals("<@" + e.getJDA().getSelfUser().getId() + ">") && args.length == 1) {
MessageBuilder mb = new MessageBuilder();
String prefix = SettingsManager.getInstance(e.getGuild().getId()).getSettings().getPrefix();
mb.append("Hello ").append(e.getAuthor()).append("! ");
if (prefix.isEmpty()) {
mb.append("This guild does not have a command prefix.");
}
else {
mb.append("You can use commands in this guild by using the prefix \"" + prefix + "\" or mention instead of using a prefix.\n"
+ "Use the help and about commands for more information.");
}
SendMessage.sendMessage(e.getChannel(), mb.build());
}
}
示例6: render
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
private Message render(int selection)
{
StringBuilder sbuilder = new StringBuilder();
for(int i=0; i<choices.size(); i++)
if(i+1==selection)
sbuilder.append("\n").append(leftEnd).append(choices.get(i)).append(rightEnd);
else
sbuilder.append("\n").append(defaultLeft).append(choices.get(i)).append(defaultRight);
MessageBuilder mbuilder = new MessageBuilder();
String content = text.apply(selection);
if(content!=null)
mbuilder.append(content);
return mbuilder.setEmbed(new EmbedBuilder()
.setColor(color.apply(selection))
.setDescription(sbuilder.toString())
.build()).build();
}
示例7: onInvoke
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public void onInvoke(Guild guild, TextChannel channel, Member invoker, Message message, String[] args) {
MessageBuilder mb = null;
List<MessageBuilder> builders = new ArrayList<>();
int i = 0;
for(FredBoat fb : FredBoat.getShards()) {
if(i % SHARDS_PER_MESSAGE == 0) {
mb = new MessageBuilder()
.append("```diff\n");
builders.add(mb);
}
mb.append(fb.getJda().getStatus() == JDA.Status.CONNECTED ? "+" : "-")
.append(" ")
.append(fb.getShardInfo().getShardString())
.append(" ")
.append(fb.getJda().getStatus())
.append(" -- Guilds: ")
.append(String.format("%04d",fb.getJda().getGuilds().size()))
.append(" -- Users: ")
.append(fb.getJda().getUsers().size())
.append("\n");
i++;
}
for(MessageBuilder builder : builders){
builder.append("```");
channel.sendMessage(builder.build()).queue();
}
}
示例8: onKingdomMessage
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public MessagePolicy onKingdomMessage(Message message) {
byte kingdomId = message.getSender().getKingdomId();
Kingdom kingdom = Kingdoms.getKingdom(kingdomId);
String kingdomName = discordifyName(kingdom.getName());
MessageBuilder builder = new MessageBuilder();
builder.append(message.getMessage());
jda.getGuildsByName(serverName, true).get(0).getTextChannelsByName(kingdomName, true).get(0).sendMessage(builder.build()).queue();
return MessagePolicy.PASS;
}
示例9: 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());
}
示例10: onCommand
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
@Override
public void onCommand(MessageReceivedEvent e, String[] args) {
GuildVoiceState state = e.getMember().getVoiceState();
if (!state.inVoiceChannel()) {
return;
}
List<Member> members = state.getChannel().getMembers();
if (members.size() <= 1) {
return;
}
MessageBuilder mb = new MessageBuilder();
String channelName = state.getChannel().getName();
int maxNameLength = 25;
if (channelName.length() > maxNameLength) {
channelName = channelName.substring(0, maxNameLength) + "...";
}
mb.append(e.getAuthor()).append(" *@" + channelName + "*: ");
members.forEach(m -> {
if (m.getUser().getId() != e.getAuthor().getId()) {
mb.append(m).append(" ");
}
});
if (args.length > 1) {
mb.append(StringUtils.join(args, " ", 1, args.length));
}
SendMessage.sendMessage(e, mb.build());
}
示例11: appendUsersRaw
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public static String appendUsersRaw(List<Player> players) {
MessageBuilder mb = new MessageBuilder();
for (int i = 0; i < players.size(); i++) {
Player p = players.get(i);
mb.append(p.getUser());
if (i < players.size() - 1) {
mb.append(", ");
}
}
return mb.build().getRawContent();
}
示例12: printConfig
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
private void printConfig(MessageReceivedEvent e) {
MessageBuilder mb = new MessageBuilder();
mb.append("Players: ");
for (int i = 0; i < getPlayers().size(); i++) {
Player p = getPlayers().get(i);
mb.append(p.getUser());
if (p.isHost()) {
mb.append("(Host)");
}
if (i < getPlayers().size() - 1) {
mb.append(", ");
}
}
mb.append("\nDedicated Channel: ");
if (dedicatedChannel == 0) {
mb.append("No\n");
}
else if (dedicatedChannel == 1) {
mb.append("Text Channel ")
.append(gameChannel)
.append("\n");
}
else if (dedicatedChannel == 2) {
mb.append("Voice Channel " + voiceChannel.getName() + "\n");
}
else if (dedicatedChannel == 3) {
mb.append("Text Channel ")
.append(gameChannel)
.append(" and Voice Channel " + voiceChannel.getName() + "\n");
}
mb.append("Voting type: " + (privateVoting ? "Private" : "Public"));
e.getTextChannel().sendMessage(mb.build());
}
示例13: execution
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public void execution(Player p) {
MessageBuilder mb = new MessageBuilder()
.append("President ")
.append(president.getUser().getName())
.append(" has chosen to execute ")
.append(p.getUser().getName())
.append(".");
sh.gameMessage(mb.build());
p.setAlive(false);
mb = new MessageBuilder().append(p.getUser())
.append(" has been executed.\n");
if (p.isHitler()) {
mb.append("Hitler has been executed!");
if (sh.getSound()) {
sh.triggers.executionHitler(president, p);
sh.triggers.executedAsHitler(p);
}
sh.results();
}
else {
mb.append(p.getUser().getName())
.append(" was not Hitler.");
if (sh.getSound()) {
sh.triggers.executionNotHitler(president, p);
sh.triggers.executedNotAsHitler(p);
}
}
sh.gameMessage(mb.build());
}
示例14: nowPlayingMessage
import net.dv8tion.jda.core.MessageBuilder; //导入方法依赖的package包/类
public static Message nowPlayingMessage(Guild guild, String successEmoji)
{
MessageBuilder mb = new MessageBuilder();
mb.append(successEmoji+" **Now Playing...**");
EmbedBuilder eb = new EmbedBuilder();
AudioHandler ah = (AudioHandler)guild.getAudioManager().getSendingHandler();
eb.setColor(guild.getSelfMember().getColor());
if(ah==null || !ah.isMusicPlaying())
{
eb.setTitle("No music playing");
eb.setDescription("\u23F9 "+FormatUtil.progressBar(-1)+" "+FormatUtil.volumeIcon(ah==null?100:ah.getPlayer().getVolume()));
}
else
{
if(ah.getRequester()!=0)
{
User u = guild.getJDA().getUserById(ah.getRequester());
if(u==null)
eb.setAuthor("Unknown (ID:"+ah.getRequester()+")", null, null);
else
eb.setAuthor(u.getName()+"#"+u.getDiscriminator(), null, u.getEffectiveAvatarUrl());
}
try {
eb.setTitle(ah.getPlayer().getPlayingTrack().getInfo().title, ah.getPlayer().getPlayingTrack().getInfo().uri);
} catch(Exception e) {
eb.setTitle(ah.getPlayer().getPlayingTrack().getInfo().title);
}
if(!AudioHandler.USE_NP_REFRESH && ah.getPlayer().getPlayingTrack() instanceof YoutubeAudioTrack)
eb.setThumbnail("https://img.youtube.com/vi/"+ah.getPlayer().getPlayingTrack().getIdentifier()+"/mqdefault.jpg");
eb.setDescription(FormatUtil.embedFormat(ah));
}
return mb.setEmbed(eb.build()).build();
}
示例15: 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();
}