public MessageBuilder(Message message) { if (message != null) { isTTS = message.isTTS(); builder.append(message.getContentRaw()); List<MessageEmbed> embeds = message.getEmbeds(); if (embeds != null && !embeds.isEmpty()) embed = embeds.get(0); } }
/** * Creates a new WebhookMessageBuilder and applies * the information of the provided {@link net.dv8tion.jda.core.entities.Message Message} * as preset values. * <br>This will not copy any attachments! * * @param message * The {@link net.dv8tion.jda.core.entities.Message Message} used * to set initial values of the builder */ public WebhookMessageBuilder(Message message) { if (message != null) { embeds.addAll(message.getEmbeds()); setContent(message.getContentRaw()); isTTS = message.isTTS(); } }
@Override public MessageAction editMessageById(String id, Message newContent) { Checks.notNull(newContent, "Message"); //checkVerification(); no verification needed to edit a message checkPermission(Permission.MESSAGE_READ); checkPermission(Permission.MESSAGE_WRITE); if (newContent.getContentRaw().isEmpty() && !newContent.getEmbeds().isEmpty()) checkPermission(Permission.MESSAGE_EMBED_LINKS); //Call MessageChannel's default return TextChannel.super.editMessageById(id, newContent); }
@Override public MessageAction sendMessage(Message msg) { Checks.notNull(msg, "Message"); checkVerification(); checkPermission(Permission.MESSAGE_READ); checkPermission(Permission.MESSAGE_WRITE); if (msg.getContentRaw().isEmpty() && !msg.getEmbeds().isEmpty()) checkPermission(Permission.MESSAGE_EMBED_LINKS); //Call MessageChannel's default return TextChannel.super.sendMessage(msg); }
/** * Applies the sendable information of the provided {@link net.dv8tion.jda.core.entities.Message Message} * to this MessageAction settings. * <br>This will override all existing settings <b>if</b> new settings are available. * * <p><b>This does not copy files!</b> * * @param message * The nullable Message to apply settings from * * @throws java.lang.IllegalArgumentException * If the message contains an {@link net.dv8tion.jda.core.entities.MessageEmbed MessageEmbed} * that exceeds the sendable character limit, * see {@link net.dv8tion.jda.core.entities.MessageEmbed#isSendable(net.dv8tion.jda.core.AccountType) MessageEmbed.isSendable(AccountType)} * * @return Updated MessageAction for chaining convenience */ @CheckReturnValue public MessageAction apply(final Message message) { if (message == null || message.getType() != MessageType.DEFAULT) return this; final List<MessageEmbed> embeds = message.getEmbeds(); if (embeds != null && !embeds.isEmpty()) embed(embeds.get(0)); files.clear(); return content(message.getContentRaw()).tts(message.isTTS()); }
/** * Creates a new WebhookMessage instance with the provided {@link net.dv8tion.jda.core.entities.Message Message} * as layout for copying. * <br><b>This does not copy the attachments of the provided message!</b> * * @param message * The message to copy * * @throws java.lang.IllegalArgumentException * If the provided message is {@code null} * * @return The resulting WebhookMessage instance */ public static WebhookMessage from(Message message) { Checks.notNull(message, "Message"); final String content = message.getContentRaw(); final List<MessageEmbed> embeds = message.getEmbeds(); final boolean isTTS = message.isTTS(); return new WebhookMessage(null, null, content, embeds, isTTS, null); }
Message built = new MessageBuilder() .setContent(event.getClient().getWarning() + " There is no music in the queue!") .setEmbed((nowp==null ? nonowp : nowp).getEmbeds().get(0)).build(); event.reply(built, m ->