-
-
Notifications
You must be signed in to change notification settings - Fork 723
/
Member.java
581 lines (551 loc) · 25.9 KB
/
Member.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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/*
* Copyright 2015-2019 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.OnlineStatus;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.Color;
import java.time.OffsetDateTime;
import java.util.EnumSet;
import java.util.List;
/**
* Represents a Guild-specific User.
*
* <p>Contains all guild-specific information about a User. (Roles, Nickname, VoiceStatus etc.)
*
* @since 3.0
*/
public interface Member extends IMentionable, IPermissionHolder
{
/**
* The user wrapped by this Entity.
*
* @return {@link net.dv8tion.jda.api.entities.User User}
*/
@Nonnull
User getUser();
/**
* The Guild in which this Member is represented.
*
* @return {@link net.dv8tion.jda.api.entities.Guild Guild}
*/
@Nonnull
Guild getGuild();
/**
* The JDA instance.
*
* @return The current JDA instance.
*/
@Nonnull
JDA getJDA();
/**
* The {@link java.time.OffsetDateTime Time} this Member joined the Guild.
*
* @return The Join Date.
*/
@Nonnull
OffsetDateTime getTimeJoined();
/**
* The time when this member boosted the guild.
* <br>Null indicates this member is not currently boosting the guild.
*
* @return The boosting time, or null if the member is not boosting
*
* @since 4.0.0
*/
@Nullable
OffsetDateTime getTimeBoosted();
/**
* The {@link net.dv8tion.jda.api.entities.GuildVoiceState VoiceState} of this Member.
* <br><b>This will be null when the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#VOICE_STATE} is disabled manually</b>
*
* <p>This can be used to get the Member's VoiceChannel using {@link GuildVoiceState#getChannel()}.
*
* @return {@link net.dv8tion.jda.api.entities.GuildVoiceState GuildVoiceState}
*/
@Nullable
GuildVoiceState getVoiceState();
/**
* The activities of the user.
* <br>If the user does not currently have any activity, this returns an empty list.
*
* @return Immutable list of {@link Activity Activities} for the user
*/
@Nonnull
List<Activity> getActivities();
/**
* Returns the {@link net.dv8tion.jda.api.OnlineStatus OnlineStatus} of the User.
* <br>If the {@link net.dv8tion.jda.api.OnlineStatus OnlineStatus} is unrecognized, will return {@link net.dv8tion.jda.api.OnlineStatus#UNKNOWN UNKNOWN}.
*
* @return The current {@link net.dv8tion.jda.api.OnlineStatus OnlineStatus} of the {@link net.dv8tion.jda.api.entities.User User}.
*/
@Nonnull
OnlineStatus getOnlineStatus();
/**
* The platform dependent {@link net.dv8tion.jda.api.OnlineStatus} of this member.
* <br>Since a user can be connected from multiple different devices such as web and mobile,
* discord specifies a status for each {@link net.dv8tion.jda.api.entities.ClientType}.
*
* <p>If a user is not online on the specified type,
* {@link net.dv8tion.jda.api.OnlineStatus#OFFLINE OFFLINE} is returned.
*
* @param type
* The type of client
*
* @throws java.lang.IllegalArgumentException
* If the provided type is null
*
* @return The status for that specific client or OFFLINE
*
* @since 4.0.0
*/
@Nonnull
OnlineStatus getOnlineStatus(@Nonnull ClientType type);
/**
* Returns the current nickname of this Member for the parent Guild.
*
* <p>This can be changed using
* {@link net.dv8tion.jda.api.entities.Guild#modifyNickname(Member, String) modifyNickname(Member, String)}.
*
* @return The nickname or null, if no nickname is set.
*/
@Nullable
String getNickname();
/**
* Retrieves the Name displayed in the official Discord Client.
*
* @return The Nickname of this Member or the Username if no Nickname is present.
*/
@Nonnull
String getEffectiveName();
/**
* The roles applied to this Member.
* <br>The roles are ordered based on their position. The highest role being at index 0
* and the lowest at the last index.
*
* <p>A Member's roles can be changed using the <b>addRolesToMember</b>, <b>removeRolesFromMember</b>, and <b>modifyMemberRoles</b>
* methods in {@link net.dv8tion.jda.api.entities.Guild Guild}.
*
* <p><b>The Public Role ({@code @everyone}) is not included in the returned immutable list of roles
* <br>It is implicit that every member holds the Public Role in a Guild thus it is not listed here!</b>
*
* @return An immutable List of {@link net.dv8tion.jda.api.entities.Role Roles} for this Member.
*/
@Nonnull
List<Role> getRoles();
/**
* The {@link java.awt.Color Color} of this Member's name in a Guild.
*
* <p>This is determined by the color of the highest role assigned to them that does not have the default color.
* <br>If all roles have default color, this returns null.
*
* @return The display Color for this Member.
*
* @see #getColorRaw()
*/
@Nullable
Color getColor();
/**
* The raw RGB value for the color of this member.
* <br>Defaulting to {@link net.dv8tion.jda.api.entities.Role#DEFAULT_COLOR_RAW Role.DEFAULT_COLOR_RAW}
* if this member uses the default color (special property, it changes depending on theme used in the client)
*
* @return The raw RGB value or the role default
*/
int getColorRaw();
/**
* The Permissions this Member holds in the specified {@link GuildChannel GuildChannel}.
* <br>Permissions returned by this may be different from {@link #getPermissions()}
* due to the GuildChannel's {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverrides}.
* <br><u>Changes to the returned set do not affect this entity directly.</u>
*
* @param channel
* The {@link GuildChannel GuildChannel} of which to get Permissions for
*
* @throws java.lang.IllegalArgumentException
* If the channel is null
*
* @return Set of Permissions granted to this Member.
*/
@Nonnull
EnumSet<Permission> getPermissions(@Nonnull GuildChannel channel);
/**
* Whether this Member can interact with the provided Member
* (kick/ban/etc.)
*
* @param member
* The target Member to check
*
* @throws NullPointerException
* if the specified Member is null
* @throws IllegalArgumentException
* if the specified Member is not from the same guild
*
* @return True, if this Member is able to interact with the specified Member
*
* @see net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Member)
*/
boolean canInteract(@Nonnull Member member);
/**
* Whether this Member can interact with the provided {@link net.dv8tion.jda.api.entities.Role Role}
* (kick/ban/move/modify/delete/etc.)
*
* @param role
* The target Role to check
*
* @throws NullPointerException
* if the specified Role is null
* @throws IllegalArgumentException
* if the specified Role is not from the same guild
*
* @return True, if this member is able to interact with the specified Role
*
* @see net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Role)
*/
boolean canInteract(@Nonnull Role role);
/**
* Whether this Member can interact with the provided {@link net.dv8tion.jda.api.entities.Emote Emote}
* (use in a message)
*
* @param emote
* The target Emote to check
*
* @throws NullPointerException
* if the specified Emote is null
* @throws IllegalArgumentException
* if the specified Emote is not from the same guild
*
* @return True, if this Member is able to interact with the specified Emote
*
* @see net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Emote)
*/
boolean canInteract(@Nonnull Emote emote);
/**
* Checks whether this member is the owner of its related {@link net.dv8tion.jda.api.entities.Guild Guild}.
*
* @return True, if this member is the owner of the attached Guild.
*/
boolean isOwner();
/**
* The default {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} for a {@link net.dv8tion.jda.api.entities.Member Member}.
* <br>This is the channel that the Discord client will default to opening when a Guild is opened for the first time
* after joining the guild.
* <br>The default channel is the channel with the highest position in which the member has
* {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} permissions. If this requirement doesn't apply for
* any channel in the guild, this method returns {@code null}.
*
* @return The {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} representing the default channel for this member
* or null if no such channel exists.
*/
@Nullable
TextChannel getDefaultChannel();
/**
* Bans this Member and deletes messages sent by the user based on the amount of delDays.
* <br>If you wish to ban a member without deleting any messages, provide delDays with a value of 0.
*
* <p>You can unban a user with {@link net.dv8tion.jda.api.entities.Guild#unban(User) Guild.unban(User)}.
*
* <p><b>Note:</b> {@link net.dv8tion.jda.api.entities.Guild#getMembers()} will still contain the
* {@link net.dv8tion.jda.api.entities.Member Member} until Discord sends the
* {@link net.dv8tion.jda.api.events.guild.member.GuildMemberLeaveEvent GuildMemberLeaveEvent}.
*
* <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 target Member cannot be banned due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The specified Member was removed from the Guild before finishing the task</li>
* </ul>
*
* @param delDays
* The history of messages, in days, that will be deleted.
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#BAN_MEMBERS} permission.
* @throws net.dv8tion.jda.api.exceptions.HierarchyException
* If the logged in account cannot ban the other user due to permission hierarchy position.
* <br>See {@link net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Member) PermissionUtil.canInteract(Member, Member)}
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If the provided amount of days (delDays) is less than 0.</li>
* <li>If the provided amount of days (delDays) is bigger than 7.</li>
* <li>If the provided member is {@code null}</li>
* </ul>
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @since 4.0.0
*/
@Nonnull
@CheckReturnValue
default AuditableRestAction<Void> ban(int delDays)
{
return getGuild().ban(this, delDays);
}
/**
* Bans this Member and deletes messages sent by the user based on the amount of delDays.
* <br>If you wish to ban a member without deleting any messages, provide delDays with a value of 0.
*
* <p>You can unban a user with {@link net.dv8tion.jda.api.entities.Guild#unban(User) Guild.unban(User)}.
*
* <p><b>Note:</b> {@link net.dv8tion.jda.api.entities.Guild#getMembers()} will still contain the
* {@link net.dv8tion.jda.api.entities.Member Member} until Discord sends the
* {@link net.dv8tion.jda.api.events.guild.member.GuildMemberLeaveEvent GuildMemberLeaveEvent}.
*
* <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 target Member cannot be banned due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The specified Member was removed from the Guild before finishing the task</li>
* </ul>
*
* @param delDays
* The history of messages, in days, that will be deleted.
* @param reason
* The reason for this action or {@code null} if there is no specified reason
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#BAN_MEMBERS} permission.
* @throws net.dv8tion.jda.api.exceptions.HierarchyException
* If the logged in account cannot ban the other user due to permission hierarchy position.
* <br>See {@link net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Member) PermissionUtil.canInteract(Member, Member)}
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If the provided amount of days (delDays) is less than 0.</li>
* <li>If the provided amount of days (delDays) is bigger than 7.</li>
* <li>If the provided member is {@code null}</li>
* </ul>
*
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @since 4.0.0
*/
@Nonnull
@CheckReturnValue
default AuditableRestAction<Void> ban(int delDays, @Nullable String reason)
{
return getGuild().ban(this, delDays, reason);
}
/**
* Kicks this Member from the {@link net.dv8tion.jda.api.entities.Guild Guild}.
*
* <p><b>Note:</b> {@link net.dv8tion.jda.api.entities.Guild#getMembers()} will still contain the {@link net.dv8tion.jda.api.entities.User User}
* until Discord sends the {@link net.dv8tion.jda.api.events.guild.member.GuildMemberLeaveEvent GuildMemberLeaveEvent}.
*
* <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 target Member cannot be kicked due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The specified Member was removed from the Guild before finishing the task</li>
* </ul>
*
* @throws java.lang.IllegalArgumentException
* If the provided member is not a Member of this Guild or is {@code null}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#KICK_MEMBERS} permission.
* @throws net.dv8tion.jda.api.exceptions.HierarchyException
* If the logged in account cannot kick the other member due to permission hierarchy position.
* <br>See {@link net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Member) PermissionUtil.canInteract(Member, Member)}
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
* Kicks the provided Member from the current Guild
*
* @since 4.0.0
*/
@Nonnull
@CheckReturnValue
default AuditableRestAction<Void> kick()
{
return getGuild().kick(this);
}
/**
* Kicks this from the {@link net.dv8tion.jda.api.entities.Guild Guild}.
*
* <p><b>Note:</b> {@link net.dv8tion.jda.api.entities.Guild#getMembers()} will still contain the {@link net.dv8tion.jda.api.entities.User User}
* until Discord sends the {@link net.dv8tion.jda.api.events.guild.member.GuildMemberLeaveEvent GuildMemberLeaveEvent}.
*
* <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 target Member cannot be kicked due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The specified Member was removed from the Guild before finishing the task</li>
* </ul>
*
* @param reason
* The reason for this action or {@code null} if there is no specified reason
*
* @throws java.lang.IllegalArgumentException
* If the provided member is not a Member of this Guild or is {@code null}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#KICK_MEMBERS} permission.
* @throws net.dv8tion.jda.api.exceptions.HierarchyException
* If the logged in account cannot kick the other member due to permission hierarchy position.
* <br>See {@link net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Member) PermissionUtil.canInteract(Member, Member)}
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
* Kicks the provided Member from the current Guild
*
* @since 4.0.0
*/
@Nonnull
@CheckReturnValue
default AuditableRestAction<Void> kick(@Nullable String reason)
{
return getGuild().kick(this, reason);
}
/**
* Sets the Guild Muted state state of this Member based on the provided
* boolean.
*
* <p><b>Note:</b> The Member's {@link net.dv8tion.jda.api.entities.GuildVoiceState#isGuildMuted() GuildVoiceState.isGuildMuted()} value won't change
* until JDA receives the {@link net.dv8tion.jda.api.events.guild.voice.GuildVoiceGuildMuteEvent GuildVoiceGuildMuteEvent} event related to this change.
*
* <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 target Member cannot be muted due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The specified Member was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#USER_NOT_CONNECTED USER_NOT_CONNECTED}
* <br>The specified Member is not connected to a voice channel</li>
* </ul>
*
* @param mute
* Whether this {@link net.dv8tion.jda.api.entities.Member Member} should be muted or unmuted.
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#VOICE_DEAF_OTHERS} permission.
* @throws java.lang.IllegalArgumentException
* If the provided member is not from this Guild or null.
* @throws java.lang.IllegalStateException
* If the provided member is not currently connected to a voice channel.
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @since 4.0.0
*/
@Nonnull
@CheckReturnValue
default AuditableRestAction<Void> mute(boolean mute)
{
return getGuild().mute(this, mute);
}
/**
* Sets the Guild Deafened state state of this Member based on the provided boolean.
*
* <p><b>Note:</b> The Member's {@link net.dv8tion.jda.api.entities.GuildVoiceState#isGuildDeafened() GuildVoiceState.isGuildDeafened()} value won't change
* until JDA receives the {@link net.dv8tion.jda.api.events.guild.voice.GuildVoiceGuildDeafenEvent GuildVoiceGuildDeafenEvent} event related to this change.
*
* <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 target Member cannot be deafened due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The specified Member was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#USER_NOT_CONNECTED USER_NOT_CONNECTED}
* <br>The specified Member is not connected to a voice channel</li>
* </ul>
*
* @param deafen
* Whether this {@link net.dv8tion.jda.api.entities.Member Member} should be deafened or undeafened.
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#VOICE_DEAF_OTHERS} permission.
* @throws IllegalArgumentException
* If the provided member is not from this Guild or null.
* @throws java.lang.IllegalStateException
* If the provided member is not currently connected to a voice channel.
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @since 4.0.0
*/
@Nonnull
@CheckReturnValue
default AuditableRestAction<Void> deafen(boolean deafen)
{
return getGuild().deafen(this, deafen);
}
/**
* Changes this Member's nickname in this guild.
* The nickname is visible to all members of this guild.
*
* <p>To change the nickname for the currently logged in account
* only the Permission {@link net.dv8tion.jda.api.Permission#NICKNAME_CHANGE NICKNAME_CHANGE} is required.
* <br>To change the nickname of <b>any</b> {@link net.dv8tion.jda.api.entities.Member Member} for this {@link net.dv8tion.jda.api.entities.Guild Guild}
* the Permission {@link net.dv8tion.jda.api.Permission#NICKNAME_MANAGE NICKNAME_MANAGE} is required.
*
* <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 nickname of the target Member is not modifiable due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The specified Member was removed from the Guild before finishing the task</li>
* </ul>
*
* @param nickname
* The new nickname of the {@link net.dv8tion.jda.api.entities.Member Member}, provide {@code null} or an
* empty String to reset the nickname
*
* @throws IllegalArgumentException
* If the specified {@link net.dv8tion.jda.api.entities.Member Member}
* is not from the same {@link net.dv8tion.jda.api.entities.Guild Guild}.
* Or if the provided member is {@code null}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* <ul>
* <li>If attempting to set nickname for self and the logged in account has neither {@link net.dv8tion.jda.api.Permission#NICKNAME_CHANGE}
* or {@link net.dv8tion.jda.api.Permission#NICKNAME_MANAGE}</li>
* <li>If attempting to set nickname for another member and the logged in account does not have {@link net.dv8tion.jda.api.Permission#NICKNAME_MANAGE}</li>
* </ul>
* @throws net.dv8tion.jda.api.exceptions.HierarchyException
* If attempting to set nickname for another member and the logged in account cannot manipulate the other user due to permission hierarchy position.
* <br>See {@link net.dv8tion.jda.internal.utils.PermissionUtil#canInteract(Member, Member) PermissionUtil.canInteract(Member, Member)}
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @since 4.0.0
*/
@Nonnull
@CheckReturnValue
default AuditableRestAction<Void> modifyNickname(@Nullable String nickname)
{
return getGuild().modifyNickname(this, nickname);
}
}