@Nonnull private static Collection<? extends Channel> getChannelsOfType(Category category, ChannelType type) { Checks.notNull(type, "ChannelType"); Checks.notNull(category, "Category"); // In the event Discord allows a new channel type to be nested in categories, // supporting them via CategoryOrderAction is just a matter of adding a new case here. switch(type) { case TEXT: return category.getTextChannels(); case VOICE: return category.getVoiceChannels(); default: throw new IllegalArgumentException("Cannot order category with specified channel type " + type); } }
public void onGuildJoin(GuildJoinEvent event) { Guild g = event.getGuild(); SQL.createServer(g); System.out.println("[Amme]System started on: " + g.getName()); Guild guild = event.getGuild(); GuildController controller = guild.getController(); new Timer().schedule(new TimerTask() { @Override public void run() { controller.createCategory("Amme").queue(cat -> { controller.modifyCategoryPositions() .selectPosition(cat.getPosition()) .moveTo(0).queue(); String[] list = {"music", "commands", "log", "randomstuff"}; Arrays.stream(list).forEach(s -> controller.createTextChannel(s).queue(chan -> chan.getManager().setParent((Category) cat).queue()) ); }); SQL.updateValue(guild, "music", event.getGuild().getTextChannelsByName("music", true).get(0).getName()); SQL.updateValue(guild, "logchannel", event.getGuild().getTextChannelsByName("log", true).get(0).getId()); SQL.updateValue(guild, "joinchannel", event.getGuild().getTextChannelsByName("randomstuff", true).get(0).getId()); } }, 5000); }
public Category getCategoryById(long id) { for(Shard s : shards) { Category c = s.getJDA().getCategoryById(id); if(c != null) return c; } return null; }
public SnowflakeCacheView<Category> getCategories() { return view(JDA::getCategoryCache); }
public VoiceChannelUpdateParentEvent(JDA api, long responseNumber, VoiceChannel channel, Category oldParent) { super(api, responseNumber, channel); this.oldParent = oldParent; }
public Category getOldParent() { return oldParent; }
public TextChannelUpdateParentEvent(JDA api, long responseNumber, TextChannel channel, Category oldParent) { super(api, responseNumber, channel); this.oldParent = oldParent; }
public CategoryDeleteEvent(JDA api, long responseNumber, Category category) { super(api, responseNumber, category); }
public GenericCategoryEvent(JDA api, long responseNumber, Category category) { super(api, responseNumber); this.category = category; }
public CategoryUpdateNameEvent(JDA api, long responseNumber, Category category, String oldName) { super(api, responseNumber, category); this.oldName = oldName; }
public GenericCategoryUpdateEvent(JDA api, long responseNumber, Category category) { super(api, responseNumber, category); }
public CategoryUpdatePositionEvent(JDA api, long responseNumber, Category category, int oldPosition) { super(api, responseNumber, category); this.oldPosition = oldPosition; }
public CategoryUpdatePermissionsEvent(JDA api, long responseNumber, Category category, List<IPermissionHolder> changed) { super(api, responseNumber, category); this.changed = changed; }
public CategoryCreateEvent(JDA api, long responseNumber, Category category) { super(api, responseNumber, category); }
/** * Creates a new CategoryOrderAction for the specified {@link net.dv8tion.jda.core.entities.Category Category} * * @param category * The target {@link net.dv8tion.jda.core.entities.Category Category} * which the new CategoryOrderAction will order channels from. * @param type * The {@link net.dv8tion.jda.core.entities.ChannelType ChannelType} that * matches the returning value of {@link net.dv8tion.jda.core.entities.Channel#getType() Channel#getType()} * for the generic {@link net.dv8tion.jda.core.entities.Channel Channel} type {@code T}. * * @throws java.lang.IllegalArgumentException * If the {@code ChannelType} is not one that can be retrieved from a {@code Category}. * Currently the only two allowed are {@link ChannelType#TEXT} and {@link ChannelType#VOICE}. */ @SuppressWarnings("unchecked") public CategoryOrderAction(Category category, ChannelType type) { super(category.getGuild(), type, (Collection<T>) getChannelsOfType(category, type)); this.category = category; }
/** * Sets the <b><u>{@link net.dv8tion.jda.core.entities.Category Parent Category}</u></b> * of the selected {@link net.dv8tion.jda.core.entities.Channel Channel}. * * * @param category * The new parent for the selected {@link net.dv8tion.jda.core.entities.Channel Channel} * * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} * @throws IllegalArgumentException * If the provided category is not from the same Guild * @throws UnsupportedOperationException * If the target is a category itself * * @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction} * <br>Update RestAction from {@link ChannelManagerUpdatable#update() #update()} * * @since 3.4.0 * * @see net.dv8tion.jda.core.managers.ChannelManagerUpdatable#getParentField() * @see net.dv8tion.jda.core.managers.ChannelManagerUpdatable#update() */ @CheckReturnValue public AuditableRestAction<Void> setParent(Category category) { return updatable.getParentField().setValue(category).update(); }
/** * The responsible {@link net.dv8tion.jda.core.entities.Category Category} * * @return The Category */ public Category getCategory() { return category; }
/** * Gets the {@link net.dv8tion.jda.core.entities.Category Category} * controlled by this CategoryOrderAction. * * @return The {@link net.dv8tion.jda.core.entities.Category Category} * of this CategoryOrderAction. */ @Nonnull public Category getCategory() { return category; }