Skip to content

Commit 9b5d49d

Browse files
jdeluccapre-commit-ci[bot]BobDotComLulalaby
authored
Add Docstring to Enum for Option descriptions, issue 1510 (#1699)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: BobDotCom <[email protected]> Co-authored-by: Lala Sabathil <[email protected]>
1 parent 75bc6fe commit 9b5d49d

File tree

3 files changed

+79
-4
lines changed

3 files changed

+79
-4
lines changed

discord/commands/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def __init__(
178178
enum_choices = []
179179
input_type_is_class = isinstance(input_type, type)
180180
if input_type_is_class and issubclass(input_type, (Enum, DiscordEnum)):
181-
description = inspect.getdoc(input_type)
181+
if description is None:
182+
description = inspect.getdoc(input_type)
182183
enum_choices = [OptionChoice(e.name, e.value) for e in input_type]
183184
value_class = enum_choices[0].value.__class__
184185
if all(isinstance(elem.value, value_class) for elem in enum_choices):

discord/enums.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ def try_value(cls, value):
210210

211211

212212
class ChannelType(Enum):
213+
"""Channel type"""
214+
213215
text = 0
214216
private = 1
215217
voice = 2
@@ -228,6 +230,8 @@ def __str__(self):
228230

229231

230232
class MessageType(Enum):
233+
"""Message type"""
234+
231235
default = 0
232236
recipient_add = 1
233237
recipient_remove = 2
@@ -256,6 +260,8 @@ class MessageType(Enum):
256260

257261

258262
class VoiceRegion(Enum):
263+
"""Voice region"""
264+
259265
us_west = "us-west"
260266
us_east = "us-east"
261267
us_south = "us-south"
@@ -285,6 +291,8 @@ def __str__(self):
285291

286292

287293
class SpeakingState(Enum):
294+
"""Speaking state"""
295+
288296
none = 0
289297
voice = 1
290298
soundshare = 2
@@ -298,6 +306,8 @@ def __int__(self):
298306

299307

300308
class VerificationLevel(Enum, comparable=True):
309+
"""Verification level"""
310+
301311
none = 0
302312
low = 1
303313
medium = 2
@@ -309,6 +319,8 @@ def __str__(self):
309319

310320

311321
class ContentFilter(Enum, comparable=True):
322+
"""Content Filter"""
323+
312324
disabled = 0
313325
no_role = 1
314326
all_members = 2
@@ -318,6 +330,8 @@ def __str__(self):
318330

319331

320332
class Status(Enum):
333+
"""Status"""
334+
321335
online = "online"
322336
offline = "offline"
323337
idle = "idle"
@@ -331,6 +345,8 @@ def __str__(self):
331345

332346

333347
class DefaultAvatar(Enum):
348+
"""Default avatar"""
349+
334350
blurple = 0
335351
grey = 1
336352
gray = 1
@@ -343,17 +359,23 @@ def __str__(self):
343359

344360

345361
class NotificationLevel(Enum, comparable=True):
362+
"""Notification level"""
363+
346364
all_messages = 0
347365
only_mentions = 1
348366

349367

350368
class AuditLogActionCategory(Enum):
369+
"""Audit log action category"""
370+
351371
create = 1
352372
delete = 2
353373
update = 3
354374

355375

356376
class AuditLogAction(Enum):
377+
"""Audit log action"""
378+
357379
guild_update = 1
358380
channel_create = 10
359381
channel_update = 11
@@ -505,6 +527,8 @@ def target_type(self) -> Optional[str]:
505527

506528

507529
class UserFlags(Enum):
530+
"""User flags"""
531+
508532
staff = 1
509533
partner = 2
510534
hypesquad = 4
@@ -529,6 +553,8 @@ class UserFlags(Enum):
529553

530554

531555
class ActivityType(Enum):
556+
"""Activity type"""
557+
532558
unknown = -1
533559
playing = 0
534560
streaming = 1
@@ -542,17 +568,23 @@ def __int__(self):
542568

543569

544570
class TeamMembershipState(Enum):
571+
"""Team membership state"""
572+
545573
invited = 1
546574
accepted = 2
547575

548576

549577
class WebhookType(Enum):
578+
"""Webhook Type"""
579+
550580
incoming = 1
551581
channel_follower = 2
552582
application = 3
553583

554584

555585
class ExpireBehaviour(Enum):
586+
"""Expire Behaviour"""
587+
556588
remove_role = 0
557589
kick = 1
558590

@@ -561,11 +593,15 @@ class ExpireBehaviour(Enum):
561593

562594

563595
class StickerType(Enum):
596+
"""Sticker type"""
597+
564598
standard = 1
565599
guild = 2
566600

567601

568602
class StickerFormatType(Enum):
603+
"""Sticker format Type"""
604+
569605
png = 1
570606
apng = 2
571607
lottie = 3
@@ -581,12 +617,16 @@ def file_extension(self) -> str:
581617

582618

583619
class InviteTarget(Enum):
620+
"""Invite target"""
621+
584622
unknown = 0
585623
stream = 1
586624
embedded_application = 2
587625

588626

589627
class InteractionType(Enum):
628+
"""Interaction type"""
629+
590630
ping = 1
591631
application_command = 2
592632
component = 3
@@ -595,6 +635,8 @@ class InteractionType(Enum):
595635

596636

597637
class InteractionResponseType(Enum):
638+
"""Interaction response type"""
639+
598640
pong = 1
599641
# ack = 2 (deprecated)
600642
# channel_message = 3 (deprecated)
@@ -607,6 +649,8 @@ class InteractionResponseType(Enum):
607649

608650

609651
class VideoQualityMode(Enum):
652+
"""Video quality mode"""
653+
610654
auto = 1
611655
full = 2
612656

@@ -615,6 +659,8 @@ def __int__(self):
615659

616660

617661
class ComponentType(Enum):
662+
"""Component type"""
663+
618664
action_row = 1
619665
button = 2
620666
select = 3
@@ -625,6 +671,8 @@ def __int__(self):
625671

626672

627673
class ButtonStyle(Enum):
674+
"""Button style"""
675+
628676
primary = 1
629677
secondary = 2
630678
success = 3
@@ -644,6 +692,8 @@ def __int__(self):
644692

645693

646694
class InputTextStyle(Enum):
695+
"""Input text style"""
696+
647697
short = 1
648698
singleline = 1
649699
paragraph = 2
@@ -652,26 +702,34 @@ class InputTextStyle(Enum):
652702

653703

654704
class ApplicationType(Enum):
705+
"""Application type"""
706+
655707
game = 1
656708
music = 2
657709
ticketed_events = 3
658710
guild_role_subscriptions = 4
659711

660712

661713
class StagePrivacyLevel(Enum):
714+
"""Stage privacy level"""
715+
662716
# public = 1 (deprecated)
663717
closed = 2
664718
guild_only = 2
665719

666720

667721
class NSFWLevel(Enum, comparable=True):
722+
"""NSFW level"""
723+
668724
default = 0
669725
explicit = 1
670726
safe = 2
671727
age_restricted = 3
672728

673729

674730
class SlashCommandOptionType(Enum):
731+
"""Slash command option type"""
732+
675733
sub_command = 1
676734
sub_command_group = 2
677735
string = 3
@@ -743,6 +801,8 @@ def from_datatype(cls, datatype):
743801

744802

745803
class EmbeddedActivity(Enum):
804+
"""Embedded activity"""
805+
746806
awkword = 879863881349087252
747807
betrayal = 773336526917861400
748808
checkers_in_the_park = 832013003968348200
@@ -777,6 +837,8 @@ class EmbeddedActivity(Enum):
777837

778838

779839
class ScheduledEventStatus(Enum):
840+
"""Scheduled event status"""
841+
780842
scheduled = 1
781843
active = 2
782844
completed = 3
@@ -788,36 +850,48 @@ def __int__(self):
788850

789851

790852
class ScheduledEventPrivacyLevel(Enum):
853+
"""Scheduled event privacy level"""
854+
791855
guild_only = 2
792856

793857
def __int__(self):
794858
return self.value
795859

796860

797861
class ScheduledEventLocationType(Enum):
862+
"""Scheduled event location type"""
863+
798864
stage_instance = 1
799865
voice = 2
800866
external = 3
801867

802868

803869
class AutoModTriggerType(Enum):
870+
"""Automod trigger type"""
871+
804872
keyword = 1
805873
harmful_link = 2
806874
spam = 3
807875
keyword_preset = 4
808876

809877

810878
class AutoModEventType(Enum):
879+
"""Automod event type"""
880+
811881
message_send = 1
812882

813883

814884
class AutoModActionType(Enum):
885+
"""Automod action type"""
886+
815887
block_message = 1
816888
send_alert_message = 2
817889
timeout = 3
818890

819891

820892
class AutoModKeywordPresetType(Enum):
893+
"""Automod keyword preset type"""
894+
821895
profanity = 1
822896
sexual_content = 2
823897
slurs = 3

docs/api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,19 +1630,19 @@ of :class:`enum.Enum`.
16301630

16311631
.. attribute:: news_thread
16321632

1633-
A news thread
1633+
A news thread.
16341634

16351635
.. versionadded:: 2.0
16361636

16371637
.. attribute:: public_thread
16381638

1639-
A public thread
1639+
A public thread.
16401640

16411641
.. versionadded:: 2.0
16421642

16431643
.. attribute:: private_thread
16441644

1645-
A private thread
1645+
A private thread.
16461646

16471647
.. versionadded:: 2.0
16481648

0 commit comments

Comments
 (0)