This repository was archived by the owner on Feb 3, 2025. It is now read-only.
Commit b908e31
committed
Add enum shortcut to option with choices
discord/ext/slash/__init__.py:
+ ChoiceEnum is the base class for the enum
* Options constructed from enums reference the enum in a private attr
* This required modifying Option.clone()
* Context converts values to enum values if the _enum is present
* Option(description) can now take a ChoiceEnum as the description
* This sets the description to the docstring, the type to STRING,
and the choices to the enum names and value
* Parameters annotated with ChoiceEnum subclasses are treated as if
annotated with Option(ChoiceEnum)
demo_bot.py:
* /math -> /numbers
+ /numbers now supports choosing the operator, using a ChoiceEnum
docs/discord-ext-slash.rst:
+ ChoiceEnum docs1 parent 25eed7c commit b908e31
File tree
3 files changed
+61
-10
lines changed- discord/ext/slash
- docs
3 files changed
+61
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
122 | 132 | | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
126 | 137 | | |
127 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
128 | 147 | | |
129 | 148 | | |
130 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
189 | 199 | | |
190 | 200 | | |
191 | 201 | | |
| |||
347 | 357 | | |
348 | 358 | | |
349 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
350 | 363 | | |
351 | 364 | | |
352 | 365 | | |
| |||
628 | 641 | | |
629 | 642 | | |
630 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
631 | 648 | | |
632 | 649 | | |
633 | 650 | | |
| |||
692 | 709 | | |
693 | 710 | | |
694 | 711 | | |
| 712 | + | |
| 713 | + | |
695 | 714 | | |
696 | 715 | | |
697 | 716 | | |
698 | 717 | | |
699 | 718 | | |
700 | 719 | | |
701 | 720 | | |
702 | | - | |
| 721 | + | |
703 | 722 | | |
704 | 723 | | |
705 | 724 | | |
| |||
732 | 751 | | |
733 | 752 | | |
734 | 753 | | |
735 | | - | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
736 | 763 | | |
737 | 764 | | |
738 | 765 | | |
| |||
764 | 791 | | |
765 | 792 | | |
766 | 793 | | |
767 | | - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
768 | 798 | | |
769 | 799 | | |
770 | 800 | | |
| |||
920 | 950 | | |
921 | 951 | | |
922 | 952 | | |
923 | | - | |
924 | | - | |
925 | | - | |
| 953 | + | |
| 954 | + | |
926 | 955 | | |
927 | 956 | | |
928 | 957 | | |
| |||
937 | 966 | | |
938 | 967 | | |
939 | 968 | | |
| 969 | + | |
| 970 | + | |
940 | 971 | | |
941 | 972 | | |
942 | 973 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
0 commit comments