/
PermissionOverrideAction.java
640 lines (600 loc) · 26.9 KB
/
PermissionOverrideAction.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
635
636
637
638
639
640
/*
* 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.requests.restaction;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.internal.utils.Checks;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;
/**
* Extension of {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction} specifically
* designed to create a {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}
* for a {@link GuildChannel GuildChannel}.
* This extension allows setting properties before executing the action.
*
* @since 3.0
*
* @see net.dv8tion.jda.api.entities.PermissionOverride#getManager()
* @see IPermissionContainer#upsertPermissionOverride(IPermissionHolder)
*/
public interface PermissionOverrideAction extends AuditableRestAction<PermissionOverride>
{
@Nonnull
@Override
PermissionOverrideAction setCheck(@Nullable BooleanSupplier checks);
@Nonnull
@Override
PermissionOverrideAction timeout(long timeout, @Nonnull TimeUnit unit);
@Nonnull
@Override
PermissionOverrideAction deadline(long timestamp);
/**
* Shortcut for {@code resetAllow().resetDeny()}.
* <br>The permission override will be empty after this operation
*
* @return The current PermissionOverrideAction for chaining convenience
*/
@Nonnull
default PermissionOverrideAction reset()
{
return resetAllow().resetDeny();
}
/**
* Resets the allowed permissions to the current original value.
* <br>For a new override this will just be 0.
*
* @return The current PermissionOverrideAction for chaining convenience
*/
@Nonnull
PermissionOverrideAction resetAllow();
/**
* Resets the denied permissions to the current original value.
* <br>For a new override this will just be 0.
*
* @return The current PermissionOverrideAction for chaining convenience
*/
@Nonnull
PermissionOverrideAction resetDeny();
//TODO-v5: Should probably be IPermissionContainer?
/**
* The {@link GuildChannel} this will be created in
*
* @return The channel
*/
@Nonnull
GuildChannel getChannel();
/**
* The {@link Role} for this override
*
* @return The role, or null if this is a member override
*/
@Nullable
Role getRole();
/**
* The {@link Member} for this override
*
* @return The member, or null if this is a role override
*/
@Nullable
Member getMember();
/**
* The {@link Guild} for this override
*
* @return The guild
*/
@Nonnull
default Guild getGuild()
{
return getChannel().getGuild();
}
/**
* The currently set of allowed permission bits.
* <br>This value represents all <b>granted</b> permissions
* in the raw bitwise representation.
*
* <p>Use {@link #getAllowedPermissions()} to retrieve a {@link java.util.List List}
* with {@link net.dv8tion.jda.api.Permission Permissions} for this value
*
* @return long value of granted permissions
*/
long getAllowed();
/**
* Set of {@link net.dv8tion.jda.api.Permission Permissions}
* that would be <b>granted</b> by the PermissionOverride that is created by this action.
* <br><u>Changes to the returned set do not affect this entity directly.</u>
*
* @return set of granted {@link net.dv8tion.jda.api.Permission Permissions}
*/
@Nonnull
default EnumSet<Permission> getAllowedPermissions()
{
return Permission.getPermissions(getAllowed());
}
/**
* The currently set of denied permission bits.
* <br>This value represents all <b>denied</b> permissions
* in the raw bitwise representation.
*
* <p>Use {@link #getDeniedPermissions()} to retrieve a {@link java.util.List List}
* with {@link net.dv8tion.jda.api.Permission Permissions} for this value
*
* @return long value of denied permissions
*/
long getDenied();
/**
* Set of {@link net.dv8tion.jda.api.Permission Permissions}
* that would be <b>denied</b> by the PermissionOverride that is created by this action.
* <br><u>Changes to the returned set do not affect this entity directly.</u>
*
* @return set of denied {@link net.dv8tion.jda.api.Permission Permissions}
*/
@Nonnull
default EnumSet<Permission> getDeniedPermissions()
{
return Permission.getPermissions(getDenied());
}
/**
* The currently set of inherited permission bits.
* <br>This value represents all permissions that are not explicitly allowed or denied
* in their raw bitwise representation.
* <br>Inherited Permissions are permissions that are defined by other rules
* from maybe other PermissionOverrides or a Role.
*
* <p>Use {@link #getInheritedPermissions()} to retrieve a {@link java.util.List List}
* with {@link net.dv8tion.jda.api.Permission Permissions} for this value
*
* @return long value of inherited permissions
*/
long getInherited();
/**
* Set of {@link net.dv8tion.jda.api.Permission Permissions}
* that would be <b>inherited</b> from other permission holders.
* <br>Permissions returned are not explicitly granted or denied!
* <br><u>Changes to the returned set do not affect this entity directly.</u>
*
* @return set of inherited {@link net.dv8tion.jda.api.Permission Permissions}
*
* @see #getInherited()
*/
@Nonnull
default EnumSet<Permission> getInheritedPermissions()
{
return Permission.getPermissions(getInherited());
}
/**
* Whether this Action will
* create a {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}
* for a {@link net.dv8tion.jda.api.entities.Member Member} or not
*
* @return True, if this is targeting a Member
* If this is {@code false} it is targeting a {@link net.dv8tion.jda.api.entities.Role Role}. ({@link #isRole()})
*/
boolean isMember();
/**
* Whether this Action will
* create a {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}
* for a {@link net.dv8tion.jda.api.entities.Role Role} or not
*
* @return True, if this is targeting a Role.
* If this is {@code false} it is targeting a {@link net.dv8tion.jda.api.entities.Member Member}. ({@link #isMember()})
*/
boolean isRole();
/**
* Sets the value of explicitly granted permissions
* using the bitwise representation of a set of {@link net.dv8tion.jda.api.Permission Permissions}.
* <br>This value can be retrieved through {@link net.dv8tion.jda.api.Permission#getRaw(net.dv8tion.jda.api.Permission...) Permissions.getRaw(Permission...)}!
* <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.api.Permission#isChannel() isChannel()} will have no affect!</b>
*
* <p>All newly granted permissions will be removed from the currently set denied permissions.
* <br>{@code allow = allowBits; deny = deny & ~allowBits;}
*
* @param allowBits
* The <b>positive</b> bits representing the granted
* permissions for the new PermissionOverride
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*
* @see #setAllowed(java.util.Collection) setAllow(Collection)
* @see #setAllowed(net.dv8tion.jda.api.Permission...) setAllow(Permission...)
*/
@Nonnull
@CheckReturnValue
PermissionOverrideAction setAllowed(long allowBits);
/**
* Sets the value of explicitly granted permissions
* using a Collection of {@link net.dv8tion.jda.api.Permission Permissions}.
* <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.api.Permission#isChannel() isChannel()} will have no affect!</b>
*
* <p>Example: {@code setAllow(EnumSet.of(Permission.VIEW_CHANNEL))}</p>
*
* @param permissions
* The Collection of Permissions representing the granted
* permissions for the new PermissionOverride.
* <br>If the provided value is {@code null} the permissions are reset to the default of none
*
* @throws java.lang.IllegalArgumentException
* If the any of the specified Permissions is {@code null}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*
* @see java.util.EnumSet EnumSet
* @see #setAllowed(net.dv8tion.jda.api.Permission...) setAllow(Permission...)
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction setAllowed(@Nullable Collection<Permission> permissions)
{
if (permissions == null || permissions.isEmpty())
return setAllowed(0);
Checks.noneNull(permissions, "Permissions");
return setAllowed(Permission.getRaw(permissions));
}
/**
* Sets the value of explicitly granted permissions
* using a set of {@link net.dv8tion.jda.api.Permission Permissions}.
* <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.api.Permission#isChannel() isChannel()} will have no affect!</b>
*
* @param permissions
* The Permissions representing the granted
* permissions for the new PermissionOverride.
* <br>If the provided value is {@code null} the permissions are reset to the default of none
*
* @throws java.lang.IllegalArgumentException
* If the any of the specified Permissions is {@code null}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction setAllowed(@Nullable Permission... permissions)
{
if (permissions == null || permissions.length == 0)
return setAllowed(0);
Checks.noneNull(permissions, "Permissions");
return setAllowed(Permission.getRaw(permissions));
}
/**
* Grants the specified permissions.
* <br>This does not override already granted permissions.
*
* @param allowBits
* The permissions to grant, in addition to already allowed permissions
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
PermissionOverrideAction grant(long allowBits);
/**
* Grants the specified permissions.
* <br>This does not override already granted permissions.
*
* @param permissions
* The permissions to grant, in addition to already allowed permissions
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
* @throws IllegalArgumentException
* If any provided argument is null
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction grant(@Nonnull Collection<Permission> permissions)
{
return grant(Permission.getRaw(permissions));
}
/**
* Grants the specified permissions.
* <br>This does not override already granted permissions.
*
* @param permissions
* The permissions to grant, in addition to already allowed permissions
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
* @throws IllegalArgumentException
* If any provided argument is null
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction grant(@Nonnull Permission... permissions)
{
return grant(Permission.getRaw(permissions));
}
/**
* Sets the value of explicitly denied permissions
* using the bitwise representation of a set of {@link net.dv8tion.jda.api.Permission Permissions}.
* <br>This value can be retrieved through {@link net.dv8tion.jda.api.Permission#getRaw(net.dv8tion.jda.api.Permission...) Permissions.getRaw(Permission...)}!
* <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.api.Permission#isChannel() isChannel()} will have no affect!</b>
*
* <p>All newly denied permissions will be removed from the currently set allowed permissions.
* <br>{@code deny = denyBits; allow = allow & ~denyBits;}
*
* @param denyBits
* The <b>positive</b> bits representing the denied
* permissions for the new PermissionOverride
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*
* @see #setDenied(java.util.Collection) setDeny(Collection)
* @see #setDenied(net.dv8tion.jda.api.Permission...) setDeny(Permission...)
*/
@Nonnull
@CheckReturnValue
PermissionOverrideAction setDenied(long denyBits);
/**
* Sets the value of explicitly denied permissions
* using a Collection of {@link net.dv8tion.jda.api.Permission Permissions}.
* <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.api.Permission#isChannel() isChannel()} will have no affect!</b>
*
* <p>Example: {@code setDeny(EnumSet.of(Permission.MESSAGE_SEND, Permission.MESSAGE_EXT_EMOJI))}</p>
*
* @param permissions
* The Collection of Permissions representing the denied
* permissions for the new PermissionOverride.
* <br>If the provided value is {@code null} the permissions are reset to the default of none
*
* @throws java.lang.IllegalArgumentException
* If the any of the specified Permissions is {@code null}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*
* @see java.util.EnumSet EnumSet
* @see #setDenied(net.dv8tion.jda.api.Permission...) setDeny(Permission...)
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction setDenied(@Nullable Collection<Permission> permissions)
{
if (permissions == null || permissions.isEmpty())
return setDenied(0);
Checks.noneNull(permissions, "Permissions");
return setDenied(Permission.getRaw(permissions));
}
/**
* Sets the value of explicitly denied permissions
* using a set of {@link net.dv8tion.jda.api.Permission Permissions}.
* <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.api.Permission#isChannel() isChannel()} will have no affect!</b>
*
* @param permissions
* The Permissions representing the denied
* permissions for the new PermissionOverride.
* <br>If the provided value is {@code null} the permissions are reset to the default of none
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
* @throws java.lang.IllegalArgumentException
* If the any of the specified Permissions is {@code null}
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction setDenied(@Nullable Permission... permissions)
{
if (permissions == null || permissions.length == 0)
return setDenied(0);
Checks.noneNull(permissions, "Permissions");
return setDenied(Permission.getRaw(permissions));
}
/**
* Denies the specified permissions.
* <br>This does not override already denied permissions.
*
* @param denyBits
* The permissions to deny, in addition to already denied permissions
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
PermissionOverrideAction deny(long denyBits);
/**
* Denies the specified permissions.
* <br>This does not override already denied permissions.
*
* @param permissions
* The permissions to deny, in addition to already denied permissions
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
* @throws IllegalArgumentException
* If any provided argument is null
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction deny(@Nonnull Collection<Permission> permissions)
{
return deny(Permission.getRaw(permissions));
}
/**
* Denies the specified permissions.
* <br>This does not override already denied permissions.
*
* @param permissions
* The permissions to deny, in addition to already denied permissions
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
* @throws IllegalArgumentException
* If any provided argument is null
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction deny(@Nonnull Permission... permissions)
{
return deny(Permission.getRaw(permissions));
}
/**
* Clears the provided {@link net.dv8tion.jda.api.Permission Permissions} bits
* from the {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}.
* <br>This will cause the provided Permissions to be inherited from other overrides or roles.
*
* @param inheritedBits
* The permissions to clear from the {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
PermissionOverrideAction clear(long inheritedBits);
/**
* Clears the provided {@link net.dv8tion.jda.api.Permission Permissions} bits
* from the {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}.
* <br>This will cause the provided Permissions to be inherited
*
* @param permissions
* The permissions to clear from the {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
* @throws IllegalArgumentException
* If any provided argument is null
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction clear(@Nonnull Collection<Permission> permissions)
{
return clear(Permission.getRaw(permissions));
}
/**
* Clears the provided {@link net.dv8tion.jda.api.Permission Permissions} bits
* from the {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}.
* <br>This will cause the provided Permissions to be inherited
*
* @param permissions
* The permissions to clear from the {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverride}
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
* @throws IllegalArgumentException
* If any provided argument is null
*
* @return The current PermissionOverrideAction - for chaining convenience
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction clear(@Nonnull Permission... permissions)
{
return clear(Permission.getRaw(permissions));
}
/**
* Combination of {@link #setAllowed(long)} and {@link #setDenied(long)}
* <br>First sets the allow bits and then the deny bits.
*
* @param allowBits
* An unsigned bitwise representation
* of granted Permissions
* @param denyBits
* An unsigned bitwise representation
* of denied Permissions
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*
* @see #setPermissions(java.util.Collection, java.util.Collection)
* @see net.dv8tion.jda.api.Permission#getRaw(net.dv8tion.jda.api.Permission...) Permission.getRaw(Permission...)
* @see net.dv8tion.jda.api.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection)
*/
@Nonnull
@CheckReturnValue
PermissionOverrideAction setPermissions(long allowBits, long denyBits);
/**
* Combination of {@link #setAllowed(java.util.Collection)} and {@link #setDenied(java.util.Collection)}
* <br>First sets the granted permissions and then the denied permissions.
* <br>If a passed collection is {@code null} it resets the represented value to {@code 0} - no permission specifics.
*
* <p>Example: {@code setPermissions(EnumSet.of(Permission.VIEW_CHANNEL), EnumSet.of(Permission.MESSAGE_SEND, Permission.MESSAGE_EXT_EMOJI))}
*
* @param grantPermissions
* A Collection of {@link net.dv8tion.jda.api.Permission Permissions}
* representing all explicitly granted Permissions for the PermissionOverride
* @param denyPermissions
* A Collection of {@link net.dv8tion.jda.api.Permission Permissions}
* representing all explicitly denied Permissions for the PermissionOverride
*
* @throws java.lang.IllegalArgumentException
* If the any of the specified Permissions is {@code null}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS}
* on the channel and tries to set permissions it does not have in the channel
*
* @return The current PermissionOverrideAction - for chaining convenience
*
* @see java.util.EnumSet EnumSet
* @see net.dv8tion.jda.api.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection)
*/
@Nonnull
@CheckReturnValue
default PermissionOverrideAction setPermissions(@Nullable Collection<Permission> grantPermissions, @Nullable Collection<Permission> denyPermissions)
{
return setAllowed(grantPermissions).setDenied(denyPermissions);
}
}