public Requester(JDA api) { this(api, api.getAccountType()); }
private void checkBot() { if (getUser().isBot() && getJDA().getAccountType() == AccountType.BOT) throw new UnsupportedOperationException("Cannot send a private message between bots."); } }
/** * Sets the {@link net.dv8tion.jda.core.entities.MessageEmbed MessageEmbed} * that should be used for this Message. * Refer to {@link net.dv8tion.jda.core.EmbedBuilder EmbedBuilder} for more information. * * @param embed * The {@link net.dv8tion.jda.core.entities.MessageEmbed MessageEmbed} that should * be attached to this message, {@code null} to use no embed. * * @throws java.lang.IllegalArgumentException * If the provided MessageEmbed is not sendable according to * {@link net.dv8tion.jda.core.entities.MessageEmbed#isSendable(net.dv8tion.jda.core.AccountType) MessageEmbed.isSendable(AccountType)}! * If the provided MessageEmbed is an unknown implementation this operation will fail as we are unable to deserialize it. * * @return Updated MessageAction for chaining convenience */ @CheckReturnValue public MessageAction embed(final MessageEmbed embed) { if (embed != null) { final AccountType type = getJDA().getAccountType(); Checks.check(embed.isSendable(type), "Provided Message contains an empty embed or an embed with a length greater than %d characters, which is the max for %s accounts!", type == AccountType.BOT ? MessageEmbed.EMBED_MAX_LENGTH_BOT : MessageEmbed.EMBED_MAX_LENGTH_CLIENT, type); } this.embed = embed; return this; }
@Override protected RequestBody finalizeData() { boolean isClient = getJDA().getAccountType() == AccountType.CLIENT; Checks.check(!isClient || (currentPassword != null && !currentPassword.isEmpty()), "Provided client account password to be used in auth is null or empty!"); JSONObject body = new JSONObject(); //Required fields. Populate with current values.. body.put("username", getSelfUser().getName()); body.put("avatar", opt(getSelfUser().getAvatarId())); if (shouldUpdate(NAME)) body.put("username", name); if (shouldUpdate(AVATAR)) body.put("avatar", avatar == null ? JSONObject.NULL : avatar.getEncoding()); if (isClient) { //Required fields. Populate with current values. body.put("password", currentPassword); body.put("email", email); if (shouldUpdate(EMAIL)) body.put("email", email); if (shouldUpdate(PASSWORD)) body.put("new_password", password); } reset(); return getRequestBody(body); }
if (getJDA().getAccountType() != AccountType.BOT || !getGuild().getSelfMember().hasPermission(this, Permission.MESSAGE_MANAGE)) return TextChannel.super.purgeMessagesById(messageIds);
@Override public Pair<String, Integer> getGatewayBot(JDA api) AccountTypeException.check(api.getAccountType(), AccountType.BOT); return new RestAction<Pair<String, Integer>>(api, Route.Misc.GATEWAY_BOT.compile())
default RestAction<Message> getMessageById(String messageId) AccountTypeException.check(getJDA().getAccountType(), AccountType.BOT); Checks.isSnowflake(messageId, "Message ID");
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.");
void initializeBotOwner() { if (botOwner == 0L) { if (jda.getAccountType() == AccountType.BOT) { botOwner = jda.asBot().getApplicationInfo().complete().getOwner().getIdLong(); } else { botOwner = jda.getSelfUser().getIdLong(); } } }
onGenericGuild((GenericGuildEvent) event); if (event.getJDA().getAccountType() == AccountType.CLIENT)