Application commands
LocalizedName = LocalisedName
module-attribute
¶
LocalizedDesc = LocalisedDesc
module-attribute
¶
InterCommandT = TypeVar('InterCommandT', InteractionCommand, AsyncCallable)
module-attribute
¶
SlashCommandT = TypeVar('SlashCommandT', SlashCommand, AsyncCallable)
module-attribute
¶
LocalisedName
¶
Bases: LocalisedField
A localisation object for names.
Source code in interactions\models\internal\application_commands.py
104 105 106 107 108 109 110 111 112 113 114 |
|
LocalisedDesc
¶
Bases: LocalisedField
A localisation object for descriptions.
Source code in interactions\models\internal\application_commands.py
117 118 119 120 121 122 123 124 125 126 127 |
|
OptionType
¶
Bases: IntEnum
Option types supported by slash commands.
Source code in interactions\models\internal\application_commands.py
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 |
|
SUB_COMMAND = 1
class-attribute
¶
SUB_COMMAND_GROUP = 2
class-attribute
¶
STRING = 3
class-attribute
¶
INTEGER = 4
class-attribute
¶
BOOLEAN = 5
class-attribute
¶
USER = 6
class-attribute
¶
CHANNEL = 7
class-attribute
¶
ROLE = 8
class-attribute
¶
MENTIONABLE = 9
class-attribute
¶
NUMBER = 10
class-attribute
¶
ATTACHMENT = 11
class-attribute
¶
resolvable_types()
classmethod
¶
A tuple of all resolvable types.
Source code in interactions\models\internal\application_commands.py
149 150 151 152 |
|
static_types()
classmethod
¶
A tuple of all static types.
Source code in interactions\models\internal\application_commands.py
154 155 156 157 |
|
command_types()
classmethod
¶
A tuple of all command types.
Source code in interactions\models\internal\application_commands.py
159 160 161 162 |
|
from_type(t)
classmethod
¶
Convert data types to their corresponding OptionType.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t | type | The datatype to convert | required |
Returns:
Type | Description |
---|---|
OptionType | None | OptionType or None |
Source code in interactions\models\internal\application_commands.py
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 |
|
CallbackType
¶
Bases: IntEnum
Types of callback supported by interaction response.
Source code in interactions\models\internal\application_commands.py
192 193 194 195 196 197 198 199 200 201 |
|
InteractionCommand
¶
Bases: BaseCommand
Represents a discord abstract interaction command.
Attributes:
Name | Type | Description |
---|---|---|
scope | Denotes whether its global or for specific guild. | |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. |
dm_permission | bool | Should this command be available in DMs. |
cmd_id | Dict[str, Snowflake_Type] | The id of this command given by discord. |
callback | Callable[..., Coroutine] | The coroutine to callback when this interaction is received. |
Source code in interactions\models\internal\application_commands.py
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 |
|
name: LocalisedName | str = attrs.field(repr=False, metadata=docs('1-32 character name') | no_export_meta, converter=LocalisedName.converter)
class-attribute
¶
scopes: List[Snowflake_Type] = attrs.field(default=[GLOBAL_SCOPE], converter=to_snowflake_list, metadata=docs('The scopes of this interaction. Global or guild ids') | no_export_meta)
class-attribute
¶
default_member_permissions: Optional[Permissions] = attrs.field(repr=False, default=None, metadata=docs('What permissions members need to have by default to use this command'))
class-attribute
¶
dm_permission: bool = attrs.field(repr=False, default=True, metadata=docs('Whether this command is enabled in DMs'))
class-attribute
¶
cmd_id: Dict[str, Snowflake_Type] = attrs.field(repr=False, factory=dict, metadata=docs('The unique IDs of this commands') | no_export_meta)
class-attribute
¶
callback: Callable[..., Coroutine] = attrs.field(repr=False, default=None, metadata=docs('The coroutine to call when this interaction is received') | no_export_meta)
class-attribute
¶
auto_defer: AutoDefer = attrs.field(default=MISSING, metadata=docs('A system to automatically defer this command after a set duration') | no_export_meta)
class-attribute
¶
nsfw: bool = attrs.field(repr=False, default=False, metadata=docs('This command should only work in NSFW channels'))
class-attribute
¶
resolved_name: str
property
¶
A representation of this interaction's name.
is_subcommand: bool
property
¶
to_dict()
¶
Source code in interactions\models\internal\application_commands.py
255 256 257 258 259 260 261 262 263 |
|
mention(scope=None)
¶
Returns a string that would mention the interaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope | Optional[Snowflake_Type] | If the command is available in multiple scope, specify which scope to get the mention for. Defaults to the first available one if not specified. | None |
Returns:
Type | Description |
---|---|
str | The markdown mention. |
Source code in interactions\models\internal\application_commands.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
get_localised_name(locale)
¶
Source code in interactions\models\internal\application_commands.py
287 288 |
|
get_cmd_id(scope)
¶
Source code in interactions\models\internal\application_commands.py
290 291 |
|
is_enabled(ctx)
¶
Check if this command is enabled in the given context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to check. | required |
Returns:
Type | Description |
---|---|
bool | Whether this command is enabled in the given context. |
Source code in interactions\models\internal\application_commands.py
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 |
|
ContextMenu
¶
Bases: InteractionCommand
Represents a discord context menu.
Attributes:
Name | Type | Description |
---|---|---|
name | LocalisedField | The name of this entry. |
type | CommandType | The type of entry (user or message). |
Source code in interactions\models\internal\application_commands.py
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 |
|
name: LocalisedField = attrs.field(repr=False, metadata=docs('1-32 character name'), converter=LocalisedField.converter)
class-attribute
¶
type: CommandType = attrs.field(repr=False, metadata=docs('The type of command, defaults to 1 if not specified'))
class-attribute
¶
to_dict()
¶
Source code in interactions\models\internal\application_commands.py
356 357 358 359 360 |
|
SlashCommandChoice
¶
Bases: DictSerializationMixin
Represents a discord slash command choice.
Attributes:
Name | Type | Description |
---|---|---|
name | LocalisedField | str | The name the user will see |
value | Union[str, int, float] | The data sent to your code when this choice is used |
Source code in interactions\models\internal\application_commands.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
|
name: LocalisedField | str = attrs.field(repr=False, converter=LocalisedField.converter)
class-attribute
¶
value: Union[str, int, float] = attrs.field(repr=False)
class-attribute
¶
as_dict()
¶
Source code in interactions\models\internal\application_commands.py
379 380 381 382 383 384 |
|
SlashCommandOption
¶
Bases: DictSerializationMixin
Represents a discord slash command option.
Attributes:
Name | Type | Description |
---|---|---|
name | LocalisedName | str | The name of this option |
type | Union[OptionType, int] | The type of option |
description | LocalisedDesc | str | str | The description of this option |
required | bool | "This option must be filled to use the command" |
choices | List[Union[SlashCommandChoice, Dict]] | A list of choices the user has to pick between |
channel_types | Optional[list[Union[ChannelType, int]]] | The channel types permitted. The option needs to be a channel |
min_value | Optional[float] | The minimum value permitted. The option needs to be an integer or float |
max_value | Optional[float] | The maximum value permitted. The option needs to be an integer or float |
min_length | Optional[int] | The minimum length of text a user can input. The option needs to be a string |
max_length | Optional[int] | The maximum length of text a user can input. The option needs to be a string |
argument_name | Optional[str] | The name of the argument to be used in the function. If not given, assumed to be the same as the name of the option |
Source code in interactions\models\internal\application_commands.py
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 |
|
name: LocalisedName | str = attrs.field(repr=False, converter=LocalisedName.converter)
class-attribute
¶
type: Union[OptionType, int] = attrs.field(repr=False)
class-attribute
¶
description: LocalisedDesc | str | str = attrs.field(repr=False, default='No Description Set', converter=LocalisedDesc.converter)
class-attribute
¶
required: bool = attrs.field(repr=False, default=True)
class-attribute
¶
autocomplete: bool = attrs.field(repr=False, default=False)
class-attribute
¶
choices: List[Union[SlashCommandChoice, Dict]] = attrs.field(repr=False, factory=list)
class-attribute
¶
channel_types: Optional[list[Union[ChannelType, int]]] = attrs.field(repr=False, default=None)
class-attribute
¶
min_value: Optional[float] = attrs.field(repr=False, default=None)
class-attribute
¶
max_value: Optional[float] = attrs.field(repr=False, default=None)
class-attribute
¶
min_length: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
max_length: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
argument_name: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
as_dict()
¶
Source code in interactions\models\internal\application_commands.py
491 492 493 494 495 496 497 498 499 500 501 502 |
|
SlashCommandParameter
¶
Source code in interactions\models\internal\application_commands.py
505 506 507 508 509 510 511 512 513 514 515 516 |
|
name: str = attrs.field()
class-attribute
¶
type: typing.Any = attrs.field()
class-attribute
¶
kind: inspect._ParameterKind = attrs.field()
class-attribute
¶
default: typing.Any = attrs.field(default=MISSING)
class-attribute
¶
converter: typing.Optional[typing.Callable] = attrs.field(default=None)
class-attribute
¶
option_name: str
property
¶
SlashCommand
¶
Bases: InteractionCommand
Source code in interactions\models\internal\application_commands.py
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 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
|
name: LocalisedName | str = attrs.field(repr=False, converter=LocalisedName.converter)
class-attribute
¶
description: LocalisedDesc | str = attrs.field(repr=False, default='No Description Set', converter=LocalisedDesc.converter)
class-attribute
¶
group_name: LocalisedName | str = attrs.field(repr=False, default=None, metadata=no_export_meta, converter=LocalisedName.converter)
class-attribute
¶
group_description: LocalisedDesc | str = attrs.field(repr=False, default='No Description Set', metadata=no_export_meta, converter=LocalisedDesc.converter)
class-attribute
¶
sub_cmd_name: LocalisedName | str = attrs.field(repr=False, default=None, metadata=no_export_meta, converter=LocalisedName.converter)
class-attribute
¶
sub_cmd_description: LocalisedDesc | str = attrs.field(repr=False, default='No Description Set', metadata=no_export_meta, converter=LocalisedDesc.converter)
class-attribute
¶
options: List[Union[SlashCommandOption, Dict]] = attrs.field(repr=False, factory=list)
class-attribute
¶
autocomplete_callbacks: dict = attrs.field(repr=False, factory=dict, metadata=no_export_meta)
class-attribute
¶
parameters: dict[str, SlashCommandParameter] = attrs.field(repr=False, factory=dict, metadata=no_export_meta)
class-attribute
¶
resolved_name: str
property
¶
is_subcommand: bool
property
¶
get_localised_name(locale)
¶
Source code in interactions\models\internal\application_commands.py
589 590 591 592 593 594 |
|
to_dict()
¶
Source code in interactions\models\internal\application_commands.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
|
options_validator(attribute, value)
¶
Source code in interactions\models\internal\application_commands.py
710 711 712 713 714 715 716 717 718 719 720 721 722 |
|
autocomplete(option_name)
¶
A decorator to declare a coroutine as an option autocomplete.
Source code in interactions\models\internal\application_commands.py
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
|
group(name=None, description='No Description Set', inherit_checks=True)
¶
Source code in interactions\models\internal\application_commands.py
745 746 747 748 749 750 751 752 753 754 755 756 757 |
|
subcommand(sub_cmd_name=MISSING, group_name=None, sub_cmd_description=MISSING, group_description=MISSING, options=None, nsfw=False, inherit_checks=True)
¶
Source code in interactions\models\internal\application_commands.py
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
|
call_callback(callback, ctx)
async
¶
Source code in interactions\models\internal\application_commands.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
|
ComponentCommand
¶
Bases: InteractionCommand
Source code in interactions\models\internal\application_commands.py
836 837 838 839 840 841 842 |
|
ModalCommand
¶
Bases: ComponentCommand
Source code in interactions\models\internal\application_commands.py
845 846 847 |
|
GlobalAutoComplete
¶
Bases: CallbackObject
Source code in interactions\models\internal\application_commands.py
869 870 871 872 |
|
name_validator(_, attr, value)
¶
Source code in interactions\models\internal\application_commands.py
86 87 88 89 90 91 |
|
desc_validator(_, attr, value)
¶
Source code in interactions\models\internal\application_commands.py
94 95 96 |
|
custom_ids_validator(*custom_id)
¶
Source code in interactions\models\internal\application_commands.py
99 100 101 |
|
global_autocomplete(option_name)
¶
Decorator for global autocomplete functions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
option_name | str | The name of the option to register the autocomplete function for | required |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], GlobalAutoComplete] | The decorator |
Source code in interactions\models\internal\application_commands.py
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 |
|
slash_command(name=MISSING, *, description=MISSING, scopes=MISSING, options=None, default_member_permissions=None, dm_permission=True, sub_cmd_name=None, group_name=None, sub_cmd_description='No Description Set', group_description='No Description Set', nsfw=False)
¶
A decorator to declare a coroutine as a slash command.
Note
While the base and group descriptions arent visible in the discord client, currently. We strongly advise defining them anyway, if you're using subcommands, as Discord has said they will be visible in one of the future ui updates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the command, defaults to the name of the coroutine. | MISSING |
description | Absent[str | LocalisedDesc] | 1-100 character description of the command | MISSING |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
options | Optional[List[Union[SlashCommandOption, Dict]]] | The parameters for the command, max 25 | None |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
dm_permission | bool | Should this command be available in DMs. | True |
sub_cmd_name | str | LocalisedName | 1-32 character name of the subcommand | None |
sub_cmd_description | str | LocalisedDesc | 1-100 character description of the subcommand | 'No Description Set' |
group_name | str | LocalisedName | 1-32 character name of the group | None |
group_description | str | LocalisedDesc | 1-100 character description of the group | 'No Description Set' |
nsfw | bool | This command should only work in NSFW channels | False |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], SlashCommand] | SlashCommand Object |
Source code in interactions\models\internal\application_commands.py
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 |
|
subcommand(base, *, subcommand_group=None, name=MISSING, description=MISSING, base_description=None, base_desc=None, base_default_member_permissions=None, base_dm_permission=True, subcommand_group_description=None, sub_group_desc=None, scopes=None, options=None, nsfw=False)
¶
A decorator specifically tailored for creating subcommands.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base | str | LocalisedName | The name of the base command | required |
subcommand_group | Optional[str | LocalisedName] | The name of the subcommand group, if any. | None |
name | Absent[str | LocalisedName] | The name of the subcommand, defaults to the name of the coroutine. | MISSING |
description | Absent[str | LocalisedDesc] | The description of the subcommand | MISSING |
base_description | Optional[str | LocalisedDesc] | The description of the base command | None |
base_desc | Optional[str | LocalisedDesc] | An alias of | None |
base_default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
base_dm_permission | bool | Should this command be available in DMs. | True |
subcommand_group_description | Optional[str | LocalisedDesc] | Description of the subcommand group | None |
sub_group_desc | Optional[str | LocalisedDesc] | An alias for | None |
scopes | List[Snowflake_Type] | None | The scopes of which this command is available, defaults to GLOBAL_SCOPE | None |
options | List[dict] | None | The options for this command | None |
nsfw | bool | This command should only work in NSFW channels | False |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], SlashCommand] | A SlashCommand object |
Source code in interactions\models\internal\application_commands.py
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
context_menu(name=MISSING, *, context_type, scopes=MISSING, default_member_permissions=None, dm_permission=True)
¶
A decorator to declare a coroutine as a Context Menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the context menu, defaults to the name of the coroutine. | MISSING |
context_type | CommandType | The type of context menu | required |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
dm_permission | bool | Should this command be available in DMs. | True |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], ContextMenu] | ContextMenu object |
Source code in interactions\models\internal\application_commands.py
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 |
|
user_context_menu(name=MISSING, *, scopes=MISSING, default_member_permissions=None, dm_permission=True)
¶
A decorator to declare a coroutine as a User Context Menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the context menu, defaults to the name of the coroutine. | MISSING |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
dm_permission | bool | Should this command be available in DMs. | True |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], ContextMenu] | ContextMenu object |
Source code in interactions\models\internal\application_commands.py
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 |
|
message_context_menu(name=MISSING, *, scopes=MISSING, default_member_permissions=None, dm_permission=True)
¶
A decorator to declare a coroutine as a Message Context Menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the context menu, defaults to the name of the coroutine. | MISSING |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
dm_permission | bool | Should this command be available in DMs. | True |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], ContextMenu] | ContextMenu object |
Source code in interactions\models\internal\application_commands.py
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 |
|
component_callback(*custom_id)
¶
Register a coroutine as a component callback.
Component callbacks work the same way as commands, just using components as a way of invoking, instead of messages. Your callback will be given a single argument, ComponentContext
Note
This can optionally take a regex pattern, which will be used to match against the custom ID of the component.
If you do not supply a custom_id
, the name of the coroutine will be used instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*custom_id | str | re.Pattern | The custom ID of the component to wait for | () |
Source code in interactions\models\internal\application_commands.py
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 |
|
modal_callback(*custom_id)
¶
Register a coroutine as a modal callback.
Modal callbacks work the same way as commands, just using modals as a way of invoking, instead of messages. Your callback will be given a single argument, ModalContext
Note
This can optionally take a regex pattern, which will be used to match against the custom ID of the modal.
If you do not supply a custom_id
, the name of the coroutine will be used instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*custom_id | str | re.Pattern | The custom ID of the modal to wait for | () |
Source code in interactions\models\internal\application_commands.py
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 |
|
slash_option(name, description, opt_type, required=False, autocomplete=False, choices=None, channel_types=None, min_value=None, max_value=None, min_length=None, max_length=None, argument_name=None)
¶
A decorator to add an option to a slash command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | 1-32 lowercase character name matching ^[\w-]{1,32}$ | required |
opt_type | Union[OptionType, int] | The type of option | required |
description | str | 1-100 character description of option | required |
required | bool | If the parameter is required or optional--default false | False |
autocomplete | bool | If autocomplete interactions are enabled for this STRING, INTEGER, or NUMBER type option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | A list of choices the user has to pick between (max 25) | None |
channel_types | Optional[list[Union[ChannelType, int]]] | The channel types permitted. The option needs to be a channel | None |
min_value | Optional[float] | The minimum value permitted. The option needs to be an integer or float | None |
max_value | Optional[float] | The maximum value permitted. The option needs to be an integer or float | None |
min_length | Optional[int] | The minimum length of text a user can input. The option needs to be a string | None |
max_length | Optional[int] | The maximum length of text a user can input. The option needs to be a string | None |
argument_name | Optional[str] | The name of the argument to be used in the function. If not given, assumed to be the same as the name of the option | None |
Source code in interactions\models\internal\application_commands.py
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 |
|
slash_default_member_permission(permission)
¶
A decorator to permissions members need to have by default to use a command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
permission | Permissions | The permissions to require for to this command | required |
Source code in interactions\models\internal\application_commands.py
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 |
|
auto_defer(enabled=True, ephemeral=False, time_until_defer=0.0)
¶
A decorator to add an auto defer to a application command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled | bool | Should the command be deferred automatically | True |
ephemeral | bool | Should the command be deferred as ephemeral | False |
time_until_defer | float | How long to wait before deferring automatically | 0.0 |
Source code in interactions\models\internal\application_commands.py
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 |
|
application_commands_to_dict(commands, client)
¶
Convert the command list into a format that would be accepted by discord.
Client.interactions
should be the variable passed to this
Source code in interactions\models\internal\application_commands.py
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 |
|
sync_needed(local_cmd, remote_cmd=None)
¶
Compares a local application command to its remote counterpart to determine if a sync is required.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
local_cmd | dict | The local json representation of the command | required |
remote_cmd | Optional[dict] | The json representation of the command from Discord | None |
Returns:
Type | Description |
---|---|
bool | Boolean indicating if a sync is needed |
Source code in interactions\models\internal\application_commands.py
1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 |
|
Created: January 28, 2023