@Override public MessageAction sendMessage(CharSequence text) { checkBot(); return PrivateChannel.super.sendMessage(text); }
@Override public MessageAction sendFile(InputStream data, String fileName, Message message) { checkBot(); return PrivateChannel.super.sendFile(data, fileName, message); }
/** * The target {@link net.dv8tion.jda.core.entities.User User} * <br>Shortcut for {@code getPrivateChannel().getUser()} * * @return The User */ public User getUser() { return channel.getUser(); }
@Override public List<RequestFuture<Void>> purgeMessages(List<? extends Message> messages) { if (messages == null || messages.isEmpty()) return Collections.emptyList(); for (Message m : messages) { if (m.getAuthor().equals(getJDA().getSelfUser())) continue; throw new IllegalArgumentException("Cannot delete messages of other users in a private channel"); } return PrivateChannel.super.purgeMessages(messages); }
public void handlePrivateMessage(PrivateChannel channel, User author, Message message) { if (security.isBanned(author)) { return; } if (CommandHandler.isCommand(null, message.getContentRaw(), mentionMe, mentionMeAlias)) { CommandHandler.process(this, channel, author, message); } else { channel.sendTyping().queue(); this.out.sendAsyncMessage(channel, this.chatBotHandler.chat(0L, message.getContentRaw(), channel), null); } }
@Override public MessageAction sendMessage(MessageEmbed embed) { checkBot(); return PrivateChannel.super.sendMessage(embed); }
os.close(); user.openPrivateChannel().complete().sendFile(image, fileName, null) .queue(); } catch (IOException | ErrorResponseException e) {
/** * The target {@link net.dv8tion.jda.core.entities.User User} * <br>Shortcut for {@code getPrivateChannel().getUser()} * * @return The User */ public User getUser() { return channel.getUser(); }
@Override public MessageAction sendMessage(Message msg) { checkBot(); return PrivateChannel.super.sendMessage(msg); }
FlareBot.LOGGER.error("Failed to write data", e); sender.openPrivateChannel().complete().sendFile(new File("data.json"), new MessageBuilder() .append('\u200B').build()).queue();
user = getJDA().getSelfUser(); else user = ((PrivateChannel) chan).getUser(); break; case GROUP:
public static void sendPM(User user, String message) { try { user.openPrivateChannel().complete() .sendMessage(message.substring(0, Math.min(message.length(), 1999))).queue(); } catch (ErrorResponseException ignored) { } }
case PRIVATE: final PrivateChannel priv = (PrivateChannel) channel; if (priv.getUser().isBot() && channel.getJDA().getAccountType() == AccountType.BOT) throw new UnsupportedOperationException("Cannot send a private message between bots.");
public static void sendPM(TextChannel channel, User user, String message) { try { user.openPrivateChannel().complete() .sendMessage(message.substring(0, Math.min(message.length(), 1999))).queue(); } catch (ErrorResponseException e) { channel.sendMessage(message).queue(); } }
User user; if (channel instanceof PrivateChannel) user = ((PrivateChannel) channel).getUser(); else if (channel instanceof Group) user = ((GroupImpl) channel).getUserMap().get(userId);
public void sendPrivateMessage(User target, String message, final Consumer<Message> onSuccess) { if (target != null && !target.isFake() && message != null && !message.isEmpty()) { botInstance.queue.add(target.openPrivateChannel(), privateChannel -> botInstance.queue.add(privateChannel.sendMessage(message), onSuccess)); } }
/** * Sends the "Thanks for Voting" message in a direct message * to the given user with the given amount of points. * * @param user The user that should received the message. * @param points The amounts of points that should be displayed in the message. */ public void SendThanksForVotingMessageInDM(@Nonnull User user, int points) { user.openPrivateChannel().queue(message -> message.sendMessage( buildThanksForVotingMessage(points) ).queue(null, RestActionUtil.ignore), RestActionUtil.ignore); }
public static void sendPM(TextChannel channel, User user, String message, String fail) { user.openPrivateChannel().queue(pc -> pc.sendMessage(message).queue(), t -> { channel.sendMessage(fail).queue(); }); }
public static void sendPM(TextChannel channel, User user, EmbedBuilder message) { try { user.openPrivateChannel().complete().sendMessage(message.build()).complete(); } catch (ErrorResponseException e) { channel.sendMessage(message.build()).queue(); } }