-
-
Notifications
You must be signed in to change notification settings - Fork 722
/
Channel.java
279 lines (258 loc) · 13.4 KB
/
Channel.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*
* Copyright 2015-2017 Austin Keener & Michael Ritter
*
* 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.core.entities;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.managers.ChannelManager;
import net.dv8tion.jda.core.managers.ChannelManagerUpdatable;
import net.dv8tion.jda.core.requests.RestAction;
import net.dv8tion.jda.core.requests.restaction.InviteAction;
import net.dv8tion.jda.core.requests.restaction.PermissionOverrideAction;
import java.util.List;
/**
* Represents a {@link net.dv8tion.jda.core.entities.Guild Guild} channel.
*/
public interface Channel extends ISnowflake
{
/**
* The human readable name of the Channel.
* <br>If no name has been set, this returns null.
*
* @return The name of this Channel
*/
String getName();
/**
* Returns the {@link net.dv8tion.jda.core.entities.Guild Guild} that this Channel is part of.
*
* @return Never-null {@link net.dv8tion.jda.core.entities.Guild Guild} that this Channel is part of.
*/
Guild getGuild();
/**
* A List of all {@link net.dv8tion.jda.core.entities.Member Members} that are in this Channel
* For {@link net.dv8tion.jda.core.entities.TextChannel TextChannels},
* this returns all Members with the {@link net.dv8tion.jda.core.Permission#MESSAGE_READ} Permission.
* In {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannels},
* this returns all Members that joined that VoiceChannel.
*
* @return A List of {@link net.dv8tion.jda.core.entities.Member Members} that are in this Channel.
*/
List<Member> getMembers();
/**
* The position this Channel is displayed at.
* <br>Higher values mean they are displayed lower in the Client. Position 0 is the top most Channel
* Channels of a {@link net.dv8tion.jda.core.entities.Guild Guild} do not have to have continuous positions
*
* @return Zero-based int of position of the Channel.
*/
int getPosition();
/**
* The actual position of the {@link net.dv8tion.jda.core.entities.Channel Channel} as stored and given by Discord.
* Role positions are actually based on a pairing of the creation time (as stored in the snowflake id)
* and the position. If 2 or more roles share the same position then they are sorted based on their creation date.
* The more recent a role was created, the lower it is in the hierarchy. This is handled by {@link #getPosition()}
* and it is most likely the method you want. If, for some reason, you want the actual position of the
* Role then this method will give you that value.
*
* @return The true, Discord stored, position of the {@link net.dv8tion.jda.core.entities.Channel Channel}.
*/
int getPositionRaw();
/**
* Returns the {@link net.dv8tion.jda.core.JDA JDA} instance of this Channel
*
* @return the corresponding JDA instance
*/
JDA getJDA();
/**
* The {@link PermissionOverride} relating to the specified {@link net.dv8tion.jda.core.entities.Member Member}.
* If there is no {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} for this {@link net.dv8tion.jda.core.entities.Channel Channel}
* relating to the provided {@link net.dv8tion.jda.core.entities.Member Member}, then this returns {@code null}.
*
* @param member
* The {@link net.dv8tion.jda.core.entities.Member Member} whose
* {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} is requested.
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}
* relating to the provided {@link net.dv8tion.jda.core.entities.Member Member}.
*/
PermissionOverride getPermissionOverride(Member member);
/**
* The {@link PermissionOverride} relating to the specified {@link net.dv8tion.jda.core.entities.Role Role}.
* If there is no {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} for this {@link net.dv8tion.jda.core.entities.Channel Channel}
* relating to the provided {@link net.dv8tion.jda.core.entities.Role Role}, then this returns {@code null}.
*
* @param role
* The {@link net.dv8tion.jda.core.entities.User Role} whose {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} is requested.
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}
* relating to the provided {@link net.dv8tion.jda.core.entities.Role Role}.
*/
PermissionOverride getPermissionOverride(Role role);
/**
* Gets all of the {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides} that are part
* of this {@link net.dv8tion.jda.core.entities.Channel Channel}.
* <br>This combines {@link net.dv8tion.jda.core.entities.Member Member} and {@link net.dv8tion.jda.core.entities.Role Role} overrides.
* If you would like only {@link net.dv8tion.jda.core.entities.Member Member} overrides or only {@link net.dv8tion.jda.core.entities.Role Role}
* overrides, use {@link #getMemberPermissionOverrides()} or {@link #getRolePermissionOverrides()} respectively.
*
* @return Possibly-empty list of all {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides}
* for this {@link net.dv8tion.jda.core.entities.Channel Channel}.
*/
List<PermissionOverride> getPermissionOverrides();
/**
* Gets all of the {@link net.dv8tion.jda.core.entities.Member Member} {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides}
* that are part of this {@link net.dv8tion.jda.core.entities.Channel Channel}.
*
* @return Possibly-empty list of all {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides}
* for {@link net.dv8tion.jda.core.entities.Member Member}
* for this {@link net.dv8tion.jda.core.entities.Channel Channel}.
*/
List<PermissionOverride> getMemberPermissionOverrides();
/**
* Gets all of the {@link net.dv8tion.jda.core.entities.Role Role} {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides}
* that are part of this {@link net.dv8tion.jda.core.entities.Channel Channel}.
*
* @return Possibly-empty list of all {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides}
* for {@link net.dv8tion.jda.core.entities.Role Roles}
* for this {@link net.dv8tion.jda.core.entities.Channel Channel}.
*/
List<PermissionOverride> getRolePermissionOverrides();
/**
* Returns the {@link net.dv8tion.jda.core.managers.ChannelManager ChannelManager} for this Channel.
* In the ChannelManager, you can modify the name, topic and position of this Channel.
*
* @return The ChannelManager of this Channel
*
* @see #getManagerUpdatable()
*/
ChannelManager getManager();
/**
* Returns the {@link net.dv8tion.jda.core.managers.ChannelManagerUpdatable ChannelManagerUpdatable} for this Channel.
* In the ChannelManager, you can modify the name, topic and position of this Channel.
* <br>This can be used to bulk update channel settings.
*
* @return The ChannelManagerUpdatable of this Channel
*
* @see #getManager()
*/
ChannelManagerUpdatable getManagerUpdatable();
/**
* Deletes this Channel.
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>If this channel was already deleted</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The send request was attempted after the account lost
* {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL Permission.MANAGE_CHANNEL} in the channel.</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If we were removed from the Guild</li>
* </ul>
*
* @throws net.dv8tion.jda.core.exceptions.PermissionException
* if the currently logged in account doesn't have {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL}
* for the channel.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction} - Type: Void
*/
RestAction<Void> delete();
/**
* Creates a {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}
* for the specified {@link net.dv8tion.jda.core.entities.Member Member} in this Channel.
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>If this channel was already deleted</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If we were removed from the Guild</li>
* </ul>
*
* @param member
* The Member to create an override for
*
* @throws net.dv8tion.jda.core.exceptions.PermissionException
* if we don't have the permission to {@link net.dv8tion.jda.core.Permission#MANAGE_PERMISSIONS MANAGE_PERMISSIONS}
* @throws IllegalArgumentException
* if the specified Member is null or the Member is not from {@link #getGuild()}
* @throws java.lang.IllegalStateException
* If the specified Member already has a PermissionOverride. Use {@link #getPermissionOverride(Member)} to retrieve it.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction} - Type: {@link net.dv8tion.jda.core.entities.PermissionOverride}
* The newly created PermissionOverride for the specified Role
*
* @see #createPermissionOverride(Role)
*/
PermissionOverrideAction createPermissionOverride(Member member);
/**
* Creates a {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}
* for the specified {@link net.dv8tion.jda.core.entities.Role Role} in this Channel.
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>If this channel was already deleted</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If we were removed from the Guild</li>
* </ul>
*
* @param role
* The Role to create an override for
*
* @throws net.dv8tion.jda.core.exceptions.PermissionException
* if we don't have the permission to {@link net.dv8tion.jda.core.Permission#MANAGE_PERMISSIONS MANAGE_PERMISSIONS}
* @throws IllegalArgumentException
* if the specified Role is null or the Role is not from {@link #getGuild()}
* @throws java.lang.IllegalStateException
* If the specified Role already has a PermissionOverride. Use {@link #getPermissionOverride(Role)} to retrieve it.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction} - Type: {@link net.dv8tion.jda.core.entities.PermissionOverride}
* The newly created PermissionOverride for the specified Role
*
* @see #createPermissionOverride(Member)
*/
PermissionOverrideAction createPermissionOverride(Role role);
/**
* Creates a new {@link net.dv8tion.jda.core.requests.restaction.InviteAction InviteAction} which can be used to create a
* new {@link net.dv8tion.jda.core.entities.Invite Invite}.
* <br>Requires {@link net.dv8tion.jda.core.Permission#CREATE_INSTANT_INVITE CREATE_INSTANT_INVITE} in this channel.
*
* @throws net.dv8tion.jda.core.exceptions.PermissionException
* if the account does not have {@link net.dv8tion.jda.core.Permission#CREATE_INSTANT_INVITE CREATE_INSTANT_INVITE} in this channel
*
* @return A new {@link net.dv8tion.jda.core.requests.restaction.InviteAction InviteAction}
*
* @see net.dv8tion.jda.core.requests.restaction.InviteAction
*/
InviteAction createInvite();
/**
* Returns all invites for this channel.
* <br>Requires {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} in this channel.
* Will throw a {@link net.dv8tion.jda.core.exceptions.PermissionException PermissionException} otherwise.
*
* @throws net.dv8tion.jda.core.exceptions.PermissionException
* if the account does not have {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} in this channel
*
* @return {@link net.dv8tion.jda.core.requests.RestAction RestAction} - Type: List{@literal <}{@link net.dv8tion.jda.core.entities.Invite Invite}{@literal >}
* <br>The list of expanded Invite objects
*
* @see net.dv8tion.jda.core.entities.Guild#getInvites()
*/
RestAction<List<Invite>> getInvites();
}