protected void checkGuild(Guild providedGuild, String comment) { if (!getGuild().equals(providedGuild)) throw new IllegalArgumentException("Provided " + comment + " is not part of this Guild!"); }
/** * The {@link net.dv8tion.jda.core.JDA JDA} instance of this GuildController * * @return the corresponding JDA instance */ public JDA getJDA() { return getGuild().getJDA(); }
/** * Modifies the positional order of {@link net.dv8tion.jda.core.entities.Guild#getTextChannels() Guild.getTextChannels()} * using a specific {@link net.dv8tion.jda.core.requests.RestAction RestAction} extension to allow moving Channels * {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveUp(int) up}/{@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveDown(int) down} * or {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveTo(int) to} a specific position. * <br>This uses <b>ascending</b> order with a 0 based index. * * <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} include: * <ul> * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNNKOWN_CHANNEL} * <br>One of the channels has been deleted before the completion of the task</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} * <br>The currently logged in account was removed from the Guild</li> * </ul> * * @return {@link net.dv8tion.jda.core.requests.restaction.order.ChannelOrderAction ChannelOrderAction} - Type: {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} */ @CheckReturnValue public ChannelOrderAction<TextChannel> modifyTextChannelPositions() { return new ChannelOrderAction<>(getGuild(), ChannelType.TEXT); }
/** * Modifies the positional order of {@link net.dv8tion.jda.core.entities.Guild#getCategories() Guild.getCategories()} * using a specific {@link net.dv8tion.jda.core.requests.RestAction RestAction} extension to allow moving Channels * {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveUp(int) up}/{@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveDown(int) down} * or {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveTo(int) to} a specific position. * <br>This uses <b>ascending</b> order with a 0 based index. * * <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} include: * <ul> * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNNKOWN_CHANNEL} * <br>One of the channels has been deleted before the completion of the task</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} * <br>The currently logged in account was removed from the Guild</li> * </ul> * * @return {@link net.dv8tion.jda.core.requests.restaction.order.ChannelOrderAction ChannelOrderAction} - Type: {@link net.dv8tion.jda.core.entities.Category Category} */ @CheckReturnValue public ChannelOrderAction<Category> modifyCategoryPositions() { return new ChannelOrderAction<>(getGuild(), ChannelType.CATEGORY); }
/** * Modifies the positional order of {@link net.dv8tion.jda.core.entities.Guild#getVoiceChannels() Guild.getVoiceChannels()} * using a specific {@link net.dv8tion.jda.core.requests.RestAction RestAction} extension to allow moving Channels * {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveUp(int) up}/{@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveDown(int) down} * or {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveTo(int) to} a specific position. * <br>This uses <b>ascending</b> order with a 0 based index. * * <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} include: * <ul> * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNNKOWN_CHANNEL} * <br>One of the channels has been deleted before the completion of the task</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} * <br>The currently logged in account was removed from the Guild</li> * </ul> * * @return {@link net.dv8tion.jda.core.requests.restaction.order.ChannelOrderAction ChannelOrderAction} - Type: {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} */ @CheckReturnValue public ChannelOrderAction<VoiceChannel> modifyVoiceChannelPositions() { return new ChannelOrderAction<>(getGuild(), ChannelType.VOICE); }
/** * Modifies the positional order of {@link net.dv8tion.jda.core.entities.Guild#getRoles() Guild.getRoles()} * using a specific {@link net.dv8tion.jda.core.requests.RestAction RestAction} extension to allow moving Roles * {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveUp(int) up}/{@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveDown(int) down} * or {@link net.dv8tion.jda.core.requests.restaction.order.OrderAction#moveTo(int) to} a specific position. * * <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} include: * <ul> * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_ROLE UNKNOWN_ROLE} * <br>One of the roles was deleted before the completion of the task</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} * <br>The currently logged in account was removed from the Guild</li> * </ul> * * @param useDiscordOrder * Defines the ordering of the OrderAction. If {@code true}, the OrderAction will be in the ordering * defined by Discord for roles, which is Descending. This means that the highest role appears at index {@code 0} * and the lowest role at index {@code n - 1}. Providing {@code false} will result in the ordering being * in ascending order, with the lower role at index {@code 0} and the highest at index {@code n - 1}. * <br>As a note: {@link net.dv8tion.jda.core.entities.Member#getRoles() Member.getRoles()} * and {@link net.dv8tion.jda.core.entities.Guild#getRoles() Guild.getRoles()} are both in descending order. * * @return {@link net.dv8tion.jda.core.requests.restaction.order.RoleOrderAction RoleOrderAction} */ @CheckReturnValue public RoleOrderAction modifyRolePositions(boolean useDiscordOrder) { return new RoleOrderAction(getGuild(), useDiscordOrder); }
protected void checkPosition(Role role) { if(!getGuild().getSelfMember().canInteract(role)) throw new HierarchyException("Can't modify a role with higher or equal highest role than yourself! Role: " + role.toString()); } }
protected void checkPosition(Member member) { if(!getGuild().getSelfMember().canInteract(member)) throw new HierarchyException("Can't modify a member with higher or equal highest role than yourself!"); }
protected void checkPermission(Permission perm) { if (!getGuild().getSelfMember().hasPermission(perm)) throw new InsufficientPermissionException(perm); }
return role.createCopy(getGuild());
return channel.createCopy(getGuild());
public AuditableRestAction<Void> kick(String userId, String reason) Member member = getGuild().getMemberById(userId); Checks.check(member != null, "The provided userId does not correspond to a member in this guild! Provided userId: %s", userId);
if (getGuild().getOwner().equals(member)) throw new HierarchyException("Cannot modify Guild Deafen status the Owner of the Guild"); Route.CompiledRoute route = Route.Guilds.MODIFY_MEMBER.compile(getGuild().getId(), member.getUser().getId()); return new AuditableRestAction<Void>(getGuild().getJDA(), route, body)
@Override protected void handleResponse(Response response, Request<Emote> request) { if (!response.isOk()) { request.onFailure(response); return; } JSONObject obj = response.getObject(); EmoteImpl emote = api.get().getEntityBuilder().createEmote((GuildImpl) getGuild(), obj, true); request.onSuccess(emote); } };