/
Member.java
634 lines (602 loc) · 28.2 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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/*
* Copyright 2015 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.annotations.Incubating;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.*;
import java.time.OffsetDateTime;
import java.util.Collection;
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
*
* @see Guild#getMember(User)
* @see Guild#getMemberCache()
* @see Guild#getMemberById(long)
* @see Guild#getMemberByTag(String)
* @see Guild#getMemberByTag(String, String)
* @see Guild#getMembersByEffectiveName(String, boolean)
* @see Guild#getMembersByName(String, boolean)
* @see Guild#getMembersByNickname(String, boolean)
* @see Guild#getMembersWithRoles(Role...)
* @see Guild#getMembers()
*/
public interface Member extends IMentionable, IPermissionHolder, IFakeable
{
/**
* 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.
* <br>If the member was loaded through a presence update (lazy loading) this will be identical
* to the creation time of the guild. You can use {@link #hasTimeJoined()} to test whether this time
* can be relied on.
*
* <p>You can use {@link Guild#retrieveMemberById(String) guild.retrieveMemberById(member.getId())}
* to load the join time.
*
* @return The time at which this user has joined the guild.
*/
@Nonnull
OffsetDateTime getTimeJoined();
/**
* Whether this member has accurate {@link #getTimeJoined()} information.
* <br>Discord doesn't always provide this information when we load members so we have to fallback
* to the {@link Guild} creation time.
*
* <p>You can use {@link Guild#retrieveMemberById(String) guild.retrieveMemberById(member.getId())}
* to load the join time.
*
* @return True, if {@link #getTimeJoined()} is accurate
*/
boolean hasTimeJoined();
/**
* 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()}.
*
* <p>This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#VOICE_STATE CacheFlag.VOICE_STATE} to be enabled!
*
* @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.
*
* <p>This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#ACTIVITY CacheFlag.ACTIVITY} to be enabled!
*
* @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}.
*
* <p>This will always return {@link OnlineStatus#OFFLINE} if {@link net.dv8tion.jda.api.utils.cache.CacheFlag#ONLINE_STATUS CacheFlag.ONLINE_STATUS} is disabled.
*
* @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.
*
* <p>This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#CLIENT_STATUS CacheFlag.CLIENT_STATUS} to be enabled!
*
* @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);
/**
* A Set of all active {@link net.dv8tion.jda.api.entities.ClientType ClientTypes} of this Member.
* Every {@link net.dv8tion.jda.api.OnlineStatus OnlineStatus} other than {@code OFFLINE} and {@code UNKNOWN}
* is interpreted as active.
* Since {@code INVISIBLE} is only possible for the SelfUser, other Members will never have ClientTypes show as
* active when actually being {@code INVISIBLE}, since they will show as {@code OFFLINE}.
* <br>If the Member is currently not active with any Client, this returns an empty Set.
* <br>When {@link net.dv8tion.jda.api.utils.cache.CacheFlag#CLIENT_STATUS CacheFlag.CLIENT_STATUS} is disabled,
* active clients will not be tracked and this will always return an empty Set.
* <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}.
*
* @return EnumSet of all active {@link net.dv8tion.jda.api.entities.ClientType ClientTypes}
*
* @since 4.0.0
*/
@Nonnull
EnumSet<ClientType> getActiveClients();
/**
* 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 {@link Guild#addRoleToMember(Member, Role)}, {@link Guild#removeRoleFromMember(Member, Role)}, and {@link Guild#modifyMemberRoles(Member, Collection, Collection)}
* 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.
*
* @see Guild#addRoleToMember(Member, Role)
* @see Guild#removeRoleFromMember(Member, Role)
* @see Guild#modifyMemberRoles(Member, Collection, Collection)
*/
@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();
/**
* 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
*/
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.)
*
* <p>If this returns true this member can assign the role to other members.
*
* @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
*/
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
*/
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();
/**
* Checks whether this member has passed the {@link net.dv8tion.jda.api.entities.Guild Guild's}
* Membership Screening requirements.
*
* @incubating Discord is still trying to figure this out
*
* @return True, if this member hasn't passed the guild's Membership Screening requirements
*
* @since 4.2.1
*/
@Incubating
boolean isPending();
/**
* 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.GuildMemberRemoveEvent GuildMemberRemoveEvent}.
*
* <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 Member#canInteract(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.GuildMemberRemoveEvent GuildMemberRemoveEvent}.
*
* <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 Member#canInteract(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.GuildMemberRemoveEvent GuildMemberRemoveEvent}.
*
* <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 Member#canInteract(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 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.Member Member}
* until Discord sends the {@link net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent GuildMemberRemoveEvent}.
*
* <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 Member#canInteract(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 #canInteract(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);
}
}