本文整理汇总了Java中net.dv8tion.jda.core.MessageBuilder类的典型用法代码示例。如果您正苦于以下问题:Java MessageBuilder类的具体用法?Java MessageBuilder怎么用?Java MessageBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageBuilder类属于net.dv8tion.jda.core包,在下文中一共展示了MessageBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
String[] args = parsedCommandInvocation.getArgs();
Message message = parsedCommandInvocation.getMessage();
//Check if enough args
if (args.length < 3) {
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "bug [message] (min. 3 args)").build()).build();
}
//Make String out of args
String text = parsedCommandInvocation.getMessage().getContentDisplay().replace(parsedCommandInvocation.getPrefix() + parsedCommandInvocation.getCommandInvocation() + " ", "");
//Post Report to Dev Server
RubiconBot.getJDA().getTextChannelById("382231366064144384").sendMessage(
new EmbedBuilder()
.setAuthor(message.getAuthor().getName() + "#" + message.getAuthor().getDiscriminator(), null, message.getAuthor().getAvatarUrl())
.setDescription("**New Bug Detected!**\n```fix\n" + text + "```")
.build()
).queue();
//User Feedback
return new MessageBuilder().setEmbed(EmbedUtil.success("Bug reported", "Successfully send the Bug to Head Developers").build()).build();
}
示例4: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
Configuration configuration = RubiconBot.getConfiguration();
if(!configuration.has(configKey)) {
configuration.set(configKey, "0");
}
if(parsedCommandInvocation.args.length == 0) {
configuration.set(configKey, "0");
return null;
}
String message = "";
for (String s : parsedCommandInvocation.args)
message += s + " ";
RubiconBot.getConfiguration().set(configKey, message);
parsedCommandInvocation.getMessage().getJDA().getPresence().setGame(Game.playing(message));
return new MessageBuilder().setEmbed(EmbedUtil.success("Status set!", "Successfully set the playing status!").build()).build();
}
示例5: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
String[] args = parsedCommandInvocation.args;
if (args.length < 3) {
return new MessageBuilder().setEmbed(EmbedUtil.error("You have to use more arguments!", "Use at least 3 arguments.").build()).build();
}
String ownerMessage = parsedCommandInvocation.getMessage().getContentDisplay().replace(parsedCommandInvocation.getPrefix() + parsedCommandInvocation.getCommandInvocation(), "");
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor("Broadcast - Awaiting Confirmation", null, parsedCommandInvocation.getMessage().getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setDescription(ownerMessage);
embedBuilder.setColor(Colors.COLOR_PRIMARY);
Message confirmMessage = parsedCommandInvocation.getMessage().getTextChannel().sendMessage(embedBuilder.build()).complete();
confirmMessage.addReaction("✅").queue();
awaitingConfirm.put(confirmMessage.getIdLong(), ownerMessage);
return null;
}
示例6: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
MySQL sql = RubiconBot.getMySQL();
sql.disconnect();
Message msg = parsedCommandInvocation.getMessage().getTextChannel().sendMessage("Restarting :robot:").complete();
Timer t = new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
msg.delete().queue();
RubiconBot.getJDA().shutdown();
}
}, 20000);
RubiconBot.initJDA();
sql.connect();
return new MessageBuilder().setEmbed(new EmbedBuilder().setDescription(":battery: Restarted :battery:").build()).build();
}
示例7: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
if (parsedCommandInvocation.getArgs().length <= 1)
return createHelpMessage();
String temp = "";
for (int i = 0; i < parsedCommandInvocation.getArgs().length; i++) {
temp += " " + parsedCommandInvocation.getArgs()[i];
}
if (temp.equals("disable")) {
RubiconBot.getMySQL().updateGuildValue(parsedCommandInvocation.getMessage().getGuild(), "leavemsg", "0");
return new MessageBuilder().setEmbed(EmbedUtil.success("Disabled", "Succesfully disabled joinmessages").build()).build();
}
RubiconBot.getMySQL().updateGuildValue(parsedCommandInvocation.getMessage().getGuild(), "joinmsg", temp.replaceFirst("null ", ""));
String up = RubiconBot.getMySQL().getGuildValue(parsedCommandInvocation.getMessage().getGuild(), "joinmsg");
return new MessageBuilder().setEmbed(new EmbedBuilder().setDescription(":white_check_mark: Successfully set joinmessage to `" + up + "`!").build()).build();
}
示例8: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
Message message = parsedCommandInvocation.getMessage();
Guild guild = message.getGuild();
TextChannel channel = message.getTextChannel();
StringBuilder rawRoles = new StringBuilder();
guild.getRoles().forEach(r -> rawRoles.append(r.getName()).append(", "));
StringBuilder roles = new StringBuilder(rawRoles.toString());
roles.replace(rawRoles.lastIndexOf(","), roles.lastIndexOf(",") + 1, "" );
EmbedBuilder serverInfo = new EmbedBuilder();
serverInfo.setColor(Colors.COLOR_PRIMARY);
serverInfo.setTitle(":desktop: Serverinfo of " + guild.getName());
serverInfo.setThumbnail(guild.getIconUrl());
serverInfo.addField("ID", "`" + guild.getId() + "`", false);
serverInfo.addField("Guildname", "`" + guild.getName() + "`", false);
serverInfo.addField("Server region", guild.getRegion().toString(), false);
serverInfo.addField("Members", String.valueOf(guild.getMembers().size()), false);
serverInfo.addField("Textchannels", String.valueOf(guild.getTextChannels().size()), false);
serverInfo.addField("Voicechannels", String.valueOf(guild.getVoiceChannels().size()), false);
serverInfo.addField("Roles", String.valueOf(guild.getRoles().size()) + "\n ```" + roles.toString() + "```", false);
serverInfo.addField("Server owner", guild.getOwner().getUser().getName() + "#" + guild.getOwner().getUser().getDiscriminator(), false);
serverInfo.addField("Server icon url", guild.getIconUrl(), false);
serverInfo.addField("Server Creation Date", guild.getCreationTime().format(DateTimeFormatter.ISO_DATE_TIME), false);
return new MessageBuilder().setEmbed(serverInfo.build()).build();
}
示例9: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
if (parsedCommandInvocation.getArgs().length < 2) {
return createHelpMessage();
}
if (parsedCommandInvocation.getMessage().getMentionedChannels().size() != 1) {
return createHelpMessage();
}
TextChannel textChannel = parsedCommandInvocation.getMessage().getMentionedChannels().get(0);
if (!parsedCommandInvocation.getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ)) {
return EmbedUtil.message(EmbedUtil.error("Error!", "I have no permissions to write in this channel."));
}
String text = parsedCommandInvocation.getMessage().getContentDisplay().replace(parsedCommandInvocation.getPrefix() + parsedCommandInvocation.getCommandInvocation() + " #" + textChannel.getName(), "");
textChannel.sendMessage(text).queue();
return new MessageBuilder().setEmbed(EmbedUtil.success("Successful", "Successful sent message in " + textChannel.getAsMention()).build()).build();
}
示例10: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
String[] args = parsedCommandInvocation.getArgs();
Message message = parsedCommandInvocation.getMessage();
Message mymsg = message.getTextChannel().sendMessage(EmbedUtil.info("Generating", "Generating QR cde").build()).complete();
if(args.length > 0){
StringBuilder text = new StringBuilder();
for(int i = 0; i < args.length; i++){
text.append(args[i]).append(" ");
}
try {
InputStream code = new URL("https://api.qrserver.com/v1/create-qr-code/?data=" + text.toString().replace(" ", "+") + "&size=220x220&margin=0").openStream();
mymsg.delete().queue();
message.getTextChannel().sendFile(code, "qrcode.png", null).queue();
} catch (IOException e) {
e.printStackTrace();
}
} else {
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "qr <text>").build()).build();
}
return null;
}
示例11: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
Message msg = parsedCommandInvocation.getMessage();
if (msg.getMentionedUsers().isEmpty()) {
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "kick <@User>").build()).build();
}
Member target = msg.getGuild().getMember(msg.getMentionedUsers().get(0));
if (!msg.getGuild().getSelfMember().canInteract(target)) {
return new MessageBuilder().setEmbed(EmbedUtil.error("No permissions", "Sorry I can't kick this User!!!").build()).build();
} else {
PrivateChannel channel = target.getUser().openPrivateChannel().complete();
channel.sendMessage(EmbedUtil.success("Kicked", "You got kicked").build()).queue();
msg.getGuild().getController().kick(target).queue();
return new MessageBuilder().setEmbed(EmbedUtil.success("Kicked", "Succesfully kicked " + target.getAsMention()).build()).build();
}
}
示例12: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
Message message = parsedCommandInvocation.getMessage();
if (message.getMentionedUsers().isEmpty())
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "unmute <@User>").build()).build();
Member target = message.getGuild().getMember(message.getMentionedUsers().get(0));
if (!message.getGuild().getSelfMember().canInteract(target))
return new MessageBuilder().setEmbed(EmbedUtil.error("No permission", "Sorry i can't unmute this use! It's a moderator or higher").build()).build();
TextChannel channel = message.getTextChannel();
if (channel.getPermissionOverride(target) == null)
channel.createPermissionOverride(target).complete();
if (!channel.getPermissionOverride(target).getDenied().contains(Permission.MESSAGE_WRITE))
return new MessageBuilder().setEmbed(EmbedUtil.error("Not muted", "This user is no muted. Use `mute <@User>` to mute him").build()).build();
message.getGuild().getTextChannels().forEach(c -> {
if (c.getPermissionOverride(target) == null)
c.createPermissionOverride(target).complete();
c.getPermissionOverride(target).getManager().grant(Permission.MESSAGE_WRITE).queue();
});
PrivateChannel targetch = target.getUser().openPrivateChannel().complete();
targetch.sendMessage(EmbedUtil.info("Unmuted", "You got unmuted on `" + message.getGuild().getName() + "` by " + message.getAuthor().getAsMention()).build()).queue();
return new MessageBuilder().setEmbed(EmbedUtil.success("Unmuted", "Successfully Unmuted " + target.getAsMention()).build()).build();
}
示例13: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
Message message = parsedCommandInvocation.getMessage();
if (message.getMentionedUsers().isEmpty())
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "mute <@User>").build()).build();
Member target = message.getGuild().getMember(message.getMentionedUsers().get(0));
if (!message.getGuild().getSelfMember().canInteract(target))
return new MessageBuilder().setEmbed(EmbedUtil.error("No permission", "Sorry i can't mute this user! His/her role is higher than yours.").build()).build();
TextChannel channel = message.getTextChannel();
if (channel.getPermissionOverride(target) == null)
channel.createPermissionOverride(target).complete();
if (channel.getPermissionOverride(target).getDenied().contains(Permission.MESSAGE_WRITE))
return new MessageBuilder().setEmbed(EmbedUtil.error("Already muted", "This user is already muted.").build()).build();
message.getGuild().getTextChannels().forEach(c -> {
if (c.getPermissionOverride(target) == null)
c.createPermissionOverride(target).complete();
c.getPermissionOverride(target).getManager().deny(Permission.MESSAGE_WRITE).queue();
});
PrivateChannel targetch = target.getUser().openPrivateChannel().complete();
targetch.sendMessage(EmbedUtil.info("Muted", "You got muted on `" + message.getGuild().getName() + "` by " + message.getAuthor().getAsMention()).build()).queue();
return new MessageBuilder().setEmbed(EmbedUtil.success("Muted", "Successfully muted " + target.getAsMention()).build()).build();
}
示例14: execute
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
Message msg = parsedCommandInvocation.getMessage();
if (msg.getMentionedUsers().isEmpty()) {
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "ban <@User>").build()).build();
}
Member target = msg.getGuild().getMember(msg.getMentionedUsers().get(0));
if (!msg.getGuild().getSelfMember().canInteract(target)) {
return new MessageBuilder().setEmbed(EmbedUtil.error("No permissions", "Sorry I can't ban this User.").build()).build();
} else {
if (!target.getUser().isBot()) {
PrivateChannel channel = target.getUser().openPrivateChannel().complete();
channel.sendMessage(EmbedUtil.success("Banned", "You got banned").build()).queue();
}
msg.getGuild().getController().ban(target, 7).queue();
return new MessageBuilder().setEmbed(EmbedUtil.success("Banned", "Successfully banned " + target.getAsMention()).build()).build();
}
}
示例15: action
import net.dv8tion.jda.core.MessageBuilder; //导入依赖的package包/类
@Override
public void action(String prefix, String[] args, MessageReceivedEvent event)
{
Guild guild = event.getGuild();
List<String> scheduleIds = Main.getScheduleManager().getSchedulesForGuild(guild.getId());
// build output main body
String content = "";
for(String sId : scheduleIds)
{
content += "<#" + sId + "> - has " + Main.getEntryManager().getEntriesFromChannel(sId).size() + " events\n";
}
String title = "Schedules on " + guild.getName(); // title for embed
String footer = scheduleIds.size() + " schedule(s)"; // footer for embed
// build embed
MessageEmbed embed = new EmbedBuilder()
.setDescription(content)
.setTitle(title)
.setFooter(footer, null).build();
Message message = new MessageBuilder().setEmbed(embed).build(); // build message
MessageUtilities.sendMsg(message, event.getTextChannel(), null); // send message
}