/
Category.java
224 lines (211 loc) · 10.3 KB
/
Category.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Copyright 2015-2020 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.dv8tion.jda.api.entities;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.requests.restaction.ChannelAction;
import net.dv8tion.jda.api.requests.restaction.order.CategoryOrderAction;
import net.dv8tion.jda.api.requests.restaction.order.ChannelOrderAction;
import net.dv8tion.jda.api.requests.restaction.order.OrderAction;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import java.util.List;
/**
* Represents a channel category in the official Discord API.
* <br>Categories are used to keep order in a Guild by dividing the channels into groups.
*
* @since 3.4.0
*
* @see Guild#getCategoryCache()
* @see Guild#getCategories()
* @see Guild#getCategoriesByName(String, boolean)
* @see Guild#getCategoryById(long)
*
* @see JDA#getCategoryCache()
* @see JDA#getCategories()
* @see JDA#getCategoriesByName(String, boolean)
* @see JDA#getCategoryById(long)
*/
public interface Category extends GuildChannel
{
/**
* All {@link GuildChannel Channels} listed
* for this Category
* <br>This may contain {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels},
* {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels},
* and {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}!
*
* @return Immutable list of all child channels
*/
@Nonnull
List<GuildChannel> getChannels();
/**
* All {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels}
* listed for this Category
*
* @return Immutable list of all child StoreChannels
*
* @since 4.0.0
*/
@Nonnull
List<StoreChannel> getStoreChannels();
/**
* All {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}
* listed for this Category
*
* @return Immutable list of all child TextChannels
*/
@Nonnull
List<TextChannel> getTextChannels();
/**
* All {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}
* listed for this Category
*
* @return Immutable list of all child VoiceChannels
*/
@Nonnull
List<VoiceChannel> getVoiceChannels();
/**
* Creates a new {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} with this Category as parent.
* For this to be successful, the logged in account has to have the
* {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} Permission in the {@link net.dv8tion.jda.api.entities.Guild Guild}.
*
* <p>This will copy all {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverrides} of this Category!
* Unless the bot is unable to sync it with this category due to permission escalation.
* See {@link IPermissionHolder#canSync(GuildChannel, GuildChannel)} for details.
*
* <p>Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The channel could not be created due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission was removed</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MAX_CHANNELS MAX_CHANNELS}
* <br>The maximum number of channels were exceeded</li>
* </ul>
*
* @param name
* The name of the TextChannel to create
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL} permission
* @throws IllegalArgumentException
* If the provided name is {@code null} or empty or greater than 100 characters in length
*
* @return A specific {@link ChannelAction ChannelAction}
* <br>This action allows to set fields for the new TextChannel before creating it
*/
@Nonnull
@CheckReturnValue
ChannelAction<TextChannel> createTextChannel(@Nonnull String name);
/**
* Creates a new {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannel} with this Category as parent.
* For this to be successful, the logged in account has to have the
* {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} Permission in the {@link net.dv8tion.jda.api.entities.Guild Guild}.
*
* <p>This will copy all {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverrides} of this Category!
* Unless the bot is unable to sync it with this category due to permission escalation.
* See {@link IPermissionHolder#canSync(GuildChannel, GuildChannel)} for details.
*
* <p>Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The channel could not be created due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission was removed</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MAX_CHANNELS MAX_CHANNELS}
* <br>The maximum number of channels were exceeded</li>
* </ul>
*
* @param name
* The name of the VoiceChannel to create
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL} permission
* @throws IllegalArgumentException
* If the provided name is {@code null} or empty or greater than 100 characters in length
*
* @return A specific {@link ChannelAction ChannelAction}
* <br>This action allows to set fields for the new VoiceChannel before creating it
*/
@Nonnull
@CheckReturnValue
ChannelAction<VoiceChannel> createVoiceChannel(@Nonnull String name);
/**
* Modifies the positional order of this Category's nested {@link #getTextChannels() TextChannels} and {@link #getStoreChannels() StoreChannels}.
* <br>This uses an extension of {@link ChannelOrderAction ChannelOrderAction}
* specialized for ordering the nested {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}
* and {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels} of this {@link net.dv8tion.jda.api.entities.Category Category}.
* <br>Like {@link ChannelOrderAction}, the returned {@link CategoryOrderAction CategoryOrderAction}
* can be used to move TextChannels/StoreChannels {@link OrderAction#moveUp(int) up},
* {@link OrderAction#moveDown(int) down}, or
* {@link 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.api.requests.ErrorResponse ErrorResponses} include:
* <ul>
* <li>{@link net.dv8tion.jda.api.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.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The currently logged in account was removed from the Guild.</li>
* </ul>
*
* @return A {@link CategoryOrderAction CategoryOrderAction} for
* ordering the Category's {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}
* and {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels}.
*/
@Nonnull
@CheckReturnValue
CategoryOrderAction modifyTextChannelPositions();
/**
* Modifies the positional order of this Category's nested {@link #getVoiceChannels() VoiceChannels}.
* <br>This uses an extension of {@link ChannelOrderAction ChannelOrderAction}
* specialized for ordering the nested {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels} of this
* {@link net.dv8tion.jda.api.entities.Category Category}.
* <br>Like {@code ChannelOrderAction}, the returned {@link CategoryOrderAction CategoryOrderAction}
* can be used to move VoiceChannels {@link OrderAction#moveUp(int) up},
* {@link OrderAction#moveDown(int) down}, or
* {@link 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.api.requests.ErrorResponse ErrorResponses} include:
* <ul>
* <li>{@link net.dv8tion.jda.api.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.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The currently logged in account was removed from the Guild.</li>
* </ul>
*
* @return A {@link CategoryOrderAction CategoryOrderAction} for
* ordering the Category's {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}.
*/
@Nonnull
@CheckReturnValue
CategoryOrderAction modifyVoiceChannelPositions();
@Nonnull
@Override
ChannelAction<Category> createCopy(@Nonnull Guild guild);
@Nonnull
@Override
ChannelAction<Category> createCopy();
}