@@ -1859,6 +1859,7 @@ def __init__(
18591859 guild_ids : Optional [Iterable [int ]] = MISSING ,
18601860 dm_permission : Optional [bool ] = None ,
18611861 default_member_permissions : Optional [Union [Permissions , int ]] = None ,
1862+ nsfw : bool = False ,
18621863 parent_cog : Optional [ClientCog ] = None ,
18631864 force_global : bool = False ,
18641865 ) -> None :
@@ -1892,6 +1893,10 @@ def __init__(
18921893 Permission(s) required to use the command. Inputting ``8`` or ``Permissions(administrator=True)`` for
18931894 example will only allow Administrators to use the command. If set to 0, nobody will be able to use it by
18941895 default. Server owners CAN override the permission requirements.
1896+ nsfw: :class:`bool`
1897+ Whether the command can only be used in age-restricted channels. Defaults to ``False``.
1898+
1899+ .. versionadded:: 2.4
18951900 parent_cog: Optional[:class:`ClientCog`]
18961901 ``ClientCog`` to forward to the callback as the ``self`` argument.
18971902 force_global: :class:`bool`
@@ -1913,6 +1918,7 @@ def __init__(
19131918 self .default_member_permissions : Optional [
19141919 Union [Permissions , int ]
19151920 ] = default_member_permissions
1921+ self .nsfw : bool = nsfw
19161922
19171923 self .force_global : bool = force_global
19181924
@@ -2114,6 +2120,8 @@ def get_payload(self, guild_id: Optional[int]) -> dict:
21142120 # the default (True) to ensure payload parity for comparisons.
21152121 ret ["dm_permission" ] = True
21162122
2123+ ret ["nsfw" ] = self .nsfw
2124+
21172125 return ret
21182126
21192127 def parse_discord_response (
@@ -2175,6 +2183,7 @@ def is_payload_valid(
21752183 "name_localizations" ,
21762184 "description_localizations" ,
21772185 "dm_permission" ,
2186+ "nsfw" ,
21782187 ):
21792188 _log .debug ("Failed check dictionary values, not valid payload." )
21802189 return False
@@ -2682,6 +2691,7 @@ def __init__(
26822691 guild_ids : Optional [Iterable [int ]] = None ,
26832692 dm_permission : Optional [bool ] = None ,
26842693 default_member_permissions : Optional [Union [Permissions , int ]] = None ,
2694+ nsfw : bool = False ,
26852695 parent_cog : Optional [ClientCog ] = None ,
26862696 force_global : bool = False ,
26872697 ) -> None :
@@ -2711,6 +2721,14 @@ def __init__(
27112721 Permission(s) required to use the command. Inputting ``8`` or ``Permissions(administrator=True)`` for
27122722 example will only allow Administrators to use the command. If set to 0, nobody will be able to use it by
27132723 default. Server owners CAN override the permission requirements.
2724+ nsfw: :class:`bool`
2725+ Whether the command can only be used in age-restricted channels. Defaults to ``False``.
2726+
2727+ .. note::
2728+
2729+ Due to a discord limitation, this can only be set for the parent command in case of a subcommand.
2730+
2731+ .. versionadded:: 2.4
27142732 parent_cog: Optional[:class:`ClientCog`]
27152733 ``ClientCog`` to forward to the callback as the ``self`` argument.
27162734 force_global: :class:`bool`
@@ -2727,6 +2745,7 @@ def __init__(
27272745 guild_ids = guild_ids ,
27282746 default_member_permissions = default_member_permissions ,
27292747 dm_permission = dm_permission ,
2748+ nsfw = nsfw ,
27302749 parent_cog = parent_cog ,
27312750 force_global = force_global ,
27322751 )
@@ -2846,6 +2865,7 @@ def __init__(
28462865 guild_ids : Optional [Iterable [int ]] = None ,
28472866 dm_permission : Optional [bool ] = None ,
28482867 default_member_permissions : Optional [Union [Permissions , int ]] = None ,
2868+ nsfw : bool = False ,
28492869 parent_cog : Optional [ClientCog ] = None ,
28502870 force_global : bool = False ,
28512871 ) -> None :
@@ -2870,6 +2890,10 @@ def __init__(
28702890 Permission(s) required to use the command. Inputting ``8`` or ``Permissions(administrator=True)`` for
28712891 example will only allow Administrators to use the command. If set to 0, nobody will be able to use it by
28722892 default. Server owners CAN override the permission requirements.
2893+ nsfw: :class:`bool`
2894+ Whether the command can only be used in age-restricted channels. Defaults to ``False``.
2895+
2896+ .. versionadded:: 2.4
28732897 parent_cog: Optional[:class:`ClientCog`]
28742898 ``ClientCog`` to forward to the callback as the ``self`` argument.
28752899 force_global: :class:`bool`
@@ -2884,6 +2908,7 @@ def __init__(
28842908 guild_ids = guild_ids ,
28852909 dm_permission = dm_permission ,
28862910 default_member_permissions = default_member_permissions ,
2911+ nsfw = nsfw ,
28872912 parent_cog = parent_cog ,
28882913 force_global = force_global ,
28892914 )
@@ -2922,6 +2947,7 @@ def __init__(
29222947 guild_ids : Optional [Iterable [int ]] = None ,
29232948 dm_permission : Optional [bool ] = None ,
29242949 default_member_permissions : Optional [Union [Permissions , int ]] = None ,
2950+ nsfw : bool = False ,
29252951 parent_cog : Optional [ClientCog ] = None ,
29262952 force_global : bool = False ,
29272953 ) -> None :
@@ -2946,6 +2972,10 @@ def __init__(
29462972 Permission(s) required to use the command. Inputting ``8`` or ``Permissions(administrator=True)`` for
29472973 example will only allow Administrators to use the command. If set to 0, nobody will be able to use it by
29482974 default. Server owners CAN override the permission requirements.
2975+ nsfw: :class:`bool`
2976+ Whether the command can only be used in age-restricted channels. Defaults to ``False``.
2977+
2978+ .. versionadded:: 2.4
29492979 parent_cog: Optional[:class:`ClientCog`]
29502980 ``ClientCog`` to forward to the callback as the ``self`` argument.
29512981 force_global: :class:`bool`
@@ -2960,6 +2990,7 @@ def __init__(
29602990 guild_ids = guild_ids ,
29612991 dm_permission = dm_permission ,
29622992 default_member_permissions = default_member_permissions ,
2993+ nsfw = nsfw ,
29632994 parent_cog = parent_cog ,
29642995 force_global = force_global ,
29652996 )
@@ -2995,6 +3026,7 @@ def slash_command(
29953026 guild_ids : Optional [Iterable [int ]] = MISSING ,
29963027 dm_permission : Optional [bool ] = None ,
29973028 default_member_permissions : Optional [Union [Permissions , int ]] = None ,
3029+ nsfw : bool = False ,
29983030 force_global : bool = False ,
29993031):
30003032 """Creates a Slash application command from the decorated function.
@@ -3024,6 +3056,14 @@ def slash_command(
30243056 Permission(s) required to use the command. Inputting ``8`` or ``Permissions(administrator=True)`` for
30253057 example will only allow Administrators to use the command. If set to 0, nobody will be able to use it by
30263058 default. Server owners CAN override the permission requirements.
3059+ nsfw: :class:`bool`
3060+ Whether the command can only be used in age-restricted channels. Defaults to ``False``.
3061+
3062+ .. note::
3063+
3064+ Due to a discord limitation, this can only be set for the parent command in case of a subcommand.
3065+
3066+ .. versionadded:: 2.4
30273067 force_global: :class:`bool`
30283068 If True, will force this command to register as a global command, even if ``guild_ids`` is set. Will still
30293069 register to guilds. Has no effect if ``guild_ids`` are never set or added to.
@@ -3042,6 +3082,7 @@ def decorator(func: Callable) -> SlashApplicationCommand:
30423082 guild_ids = guild_ids ,
30433083 dm_permission = dm_permission ,
30443084 default_member_permissions = default_member_permissions ,
3085+ nsfw = nsfw ,
30453086 force_global = force_global ,
30463087 )
30473088 return app_cmd
@@ -3056,6 +3097,7 @@ def message_command(
30563097 guild_ids : Optional [Iterable [int ]] = MISSING ,
30573098 dm_permission : Optional [bool ] = None ,
30583099 default_member_permissions : Optional [Union [Permissions , int ]] = None ,
3100+ nsfw : bool = False ,
30593101 force_global : bool = False ,
30603102):
30613103 """Creates a Message context command from the decorated function.
@@ -3079,6 +3121,10 @@ def message_command(
30793121 Permission(s) required to use the command. Inputting ``8`` or ``Permissions(administrator=True)`` for
30803122 example will only allow Administrators to use the command. If set to 0, nobody will be able to use it by
30813123 default. Server owners CAN override the permission requirements.
3124+ nsfw: :class:`bool`
3125+ Whether the command can only be used in age-restricted channels. Defaults to ``False``.
3126+
3127+ .. versionadded:: 2.4
30823128 force_global: :class:`bool`
30833129 If True, will force this command to register as a global command, even if ``guild_ids`` is set. Will still
30843130 register to guilds. Has no effect if ``guild_ids`` are never set or added to.
@@ -3095,6 +3141,7 @@ def decorator(func: Callable) -> MessageApplicationCommand:
30953141 guild_ids = guild_ids ,
30963142 dm_permission = dm_permission ,
30973143 default_member_permissions = default_member_permissions ,
3144+ nsfw = nsfw ,
30983145 force_global = force_global ,
30993146 )
31003147 return app_cmd
@@ -3109,6 +3156,7 @@ def user_command(
31093156 guild_ids : Optional [Iterable [int ]] = MISSING ,
31103157 dm_permission : Optional [bool ] = None ,
31113158 default_member_permissions : Optional [Union [Permissions , int ]] = None ,
3159+ nsfw : bool = False ,
31123160 force_global : bool = False ,
31133161):
31143162 """Creates a User context command from the decorated function.
@@ -3132,6 +3180,10 @@ def user_command(
31323180 Permission(s) required to use the command. Inputting ``8`` or ``Permissions(administrator=True)`` for
31333181 example will only allow Administrators to use the command. If set to 0, nobody will be able to use it by
31343182 default. Server owners CAN override the permission requirements.
3183+ nsfw: :class:`bool`
3184+ Whether the command can only be used in age-restricted channels. Defaults to ``False``.
3185+
3186+ .. versionadded:: 2.4
31353187 force_global: :class:`bool`
31363188 If True, will force this command to register as a global command, even if ``guild_ids`` is set. Will still
31373189 register to guilds. Has no effect if ``guild_ids`` are never set or added to.
@@ -3148,6 +3200,7 @@ def decorator(func: Callable) -> UserApplicationCommand:
31483200 guild_ids = guild_ids ,
31493201 dm_permission = dm_permission ,
31503202 default_member_permissions = default_member_permissions ,
3203+ nsfw = nsfw ,
31513204 force_global = force_global ,
31523205 )
31533206 return app_cmd
0 commit comments