diff --git a/discord/abc.py b/discord/abc.py index b9b9ce7ab..2bb5f3f30 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -546,6 +546,9 @@ class GuildChannel: .. versionchanged:: 2.0 The object passed in can now be a role object. + .. versionchanged:: 2.0 + ``obj`` parameter is now positional-only. + Parameters ---------- obj: Union[:class:`~discord.Member`, :class:`~discord.Role`] diff --git a/discord/channel.py b/discord/channel.py index 38fe6e0a9..229e7531a 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -360,7 +360,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): {'topic': self.topic, 'nsfw': self.nsfw, 'rate_limit_per_user': self.slowmode_delay}, name=name, reason=reason ) - async def delete_messages(self, messages: Iterable[Snowflake]) -> None: + async def delete_messages(self, messages: Iterable[Snowflake], /) -> None: """|coro| Deletes a list of messages. This is similar to :meth:`Message.delete` @@ -376,6 +376,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): You must have the :attr:`~Permissions.manage_messages` permission to use this. + .. versionchanged:: 2.0 + + ``messages`` parameter is now positional-only. + Parameters ----------- messages: Iterable[:class:`abc.Snowflake`] @@ -639,6 +643,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): .. versionadded:: 1.6 + .. versionchanged:: 2.0 + + ``message_id`` parameter is now positional-only. + Parameters ------------ message_id: :class:`int` @@ -1796,6 +1804,10 @@ class DMChannel(discord.abc.Messageable, Hashable): - :attr:`~Permissions.send_tts_messages`: You cannot send TTS messages in a DM. - :attr:`~Permissions.manage_messages`: You cannot delete others messages in a DM. + .. versionchanged:: 2.0 + + ``obj`` parameter is now positional-only. + Parameters ----------- obj: :class:`User` @@ -1822,6 +1834,10 @@ class DMChannel(discord.abc.Messageable, Hashable): .. versionadded:: 1.6 + .. versionchanged:: 2.0 + + ``message_id`` parameter is now positional-only. + Parameters ------------ message_id: :class:`int` @@ -1943,6 +1959,10 @@ class GroupChannel(discord.abc.Messageable, Hashable): This also checks the kick_members permission if the user is the owner. + .. versionchanged:: 2.0 + + ``obj`` parameter is now positional-only. + Parameters ----------- obj: :class:`~discord.abc.Snowflake` @@ -2028,6 +2048,10 @@ class PartialMessageable(discord.abc.Messageable, Hashable): This is useful if you want to work with a message and only have its ID without doing an unnecessary API call. + .. versionchanged:: 2.0 + + ``message_id`` parameter is now positional-only. + Parameters ------------ message_id: :class:`int` diff --git a/discord/client.py b/discord/client.py index b6198d109..0e2a106a6 100644 --- a/discord/client.py +++ b/discord/client.py @@ -741,6 +741,10 @@ class Client: def get_channel(self, id: int, /) -> Optional[Union[GuildChannel, Thread, PrivateChannel]]: """Returns a channel or thread with the given ID. + .. versionchanged:: 2.0 + + ``id`` parameter is now positional-only. + Parameters ----------- id: :class:`int` @@ -800,6 +804,10 @@ class Client: def get_guild(self, id: int, /) -> Optional[Guild]: """Returns a guild with the given ID. + .. versionchanged:: 2.0 + + ``id`` parameter is now positional-only. + Parameters ----------- id: :class:`int` @@ -815,6 +823,10 @@ class Client: def get_user(self, id: int, /) -> Optional[User]: """Returns a user with the given ID. + .. versionchanged:: 2.0 + + ``id`` parameter is now positional-only. + Parameters ----------- id: :class:`int` @@ -830,6 +842,10 @@ class Client: def get_emoji(self, id: int, /) -> Optional[Emoji]: """Returns an emoji with the given ID. + .. versionchanged:: 2.0 + + ``id`` parameter is now positional-only. + Parameters ----------- id: :class:`int` @@ -1205,6 +1221,10 @@ class Client: This method is an API call. For general usage, consider :meth:`get_guild` instead. + .. versionchanged:: 2.0 + + ``guild_id`` parameter is now positional-only. + Parameters ----------- guild_id: :class:`int` @@ -1239,6 +1259,10 @@ class Client: Bot accounts in more than 10 guilds are not allowed to create guilds. + .. versionchanged:: 2.0 + + ``name`` and ``region``, and ``icon`` parameters are now keyword-only. + Parameters ---------- name: :class:`str` @@ -1352,7 +1376,7 @@ class Client: data = await self.http.get_invite(invite_id, with_counts=with_counts, with_expiration=with_expiration) return Invite.from_incomplete(state=self._connection, data=data) - async def delete_invite(self, invite: Union[Invite, str]) -> None: + async def delete_invite(self, invite: Union[Invite, str], /) -> None: """|coro| Revokes an :class:`.Invite`, URL, or ID to an invite. @@ -1360,6 +1384,10 @@ class Client: You must have the :attr:`~.Permissions.manage_channels` permission in the associated guild to do this. + .. versionchanged:: 2.0 + + ``invite`` parameter is now positional-only. + Parameters ---------- invite: Union[:class:`.Invite`, :class:`str`] @@ -1389,6 +1417,10 @@ class Client: The guild must have the widget enabled to get this information. + .. versionchanged:: 2.0 + + ``guild_id`` parameter is now positional-only. + Parameters ----------- guild_id: :class:`int` @@ -1441,6 +1473,10 @@ class Client: This method is an API call. If you have :attr:`discord.Intents.members` and member cache enabled, consider :meth:`get_user` instead. + .. versionchanged:: 2.0 + + ``user_id`` parameter is now positional-only. + Parameters ----------- user_id: :class:`int` @@ -1472,6 +1508,10 @@ class Client: .. versionadded:: 1.2 + .. versionchanged:: 2.0 + + ``channel_id`` parameter is now positional-only. + Raises ------- :exc:`.InvalidData` @@ -1511,6 +1551,10 @@ class Client: Retrieves a :class:`.Webhook` with the specified ID. + .. versionchanged:: 2.0 + + ``webhook_id`` parameter is now positional-only. + Raises -------- :exc:`.HTTPException` diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index b4da61001..c111be056 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -227,12 +227,16 @@ class BotBase(GroupMixin): self.add_check(func) # type: ignore return func - def add_check(self, func: Check, *, call_once: bool = False) -> None: + def add_check(self, func: Check, /, *, call_once: bool = False) -> None: """Adds a global check to the bot. This is the non-decorator interface to :meth:`.check` and :meth:`.check_once`. + .. versionchanged:: 2.0 + + ``func`` parameter is now positional-only. + Parameters ----------- func @@ -247,12 +251,16 @@ class BotBase(GroupMixin): else: self._checks.append(func) - def remove_check(self, func: Check, *, call_once: bool = False) -> None: + def remove_check(self, func: Check, /, *, call_once: bool = False) -> None: """Removes a global check from the bot. This function is idempotent and will not raise an exception if the function is not in the global checks. + .. versionchanged:: 2.0 + + ``func`` parameter is now positional-only. + Parameters ----------- func @@ -510,7 +518,7 @@ class BotBase(GroupMixin): # cogs - def add_cog(self, cog: Cog, *, override: bool = False) -> None: + def add_cog(self, cog: Cog, /, *, override: bool = False) -> None: """Adds a "cog" to the bot. A cog is a class that has its own event listeners and commands. @@ -520,6 +528,10 @@ class BotBase(GroupMixin): :exc:`.ClientException` is raised when a cog with the same name is already loaded. + .. versionchanged:: 2.0 + + ``cog`` parameter is now positional-only. + Parameters ----------- cog: :class:`.Cog` @@ -554,11 +566,15 @@ class BotBase(GroupMixin): cog = cog._inject(self) self.__cogs[cog_name] = cog - def get_cog(self, name: str) -> Optional[Cog]: + def get_cog(self, name: str, /) -> Optional[Cog]: """Gets the cog instance requested. If the cog is not found, ``None`` is returned instead. + .. versionchanged:: 2.0 + + ``name`` parameter is now positional-only. + Parameters ----------- name: :class:`str` @@ -573,7 +589,7 @@ class BotBase(GroupMixin): """ return self.__cogs.get(name) - def remove_cog(self, name: str) -> Optional[Cog]: + def remove_cog(self, name: str, /) -> Optional[Cog]: """Removes a cog from the bot and returns it. All registered commands and event listeners that the @@ -581,6 +597,10 @@ class BotBase(GroupMixin): If no cog is found then this method has no effect. + .. versionchanged:: 2.0 + + ``name`` parameter is now positional-only. + Parameters ----------- name: :class:`str` diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index 38a24d1db..75bd99874 100644 --- a/discord/ext/commands/context.py +++ b/discord/ext/commands/context.py @@ -170,6 +170,10 @@ class Context(discord.abc.Messageable, Generic[BotT]): You must take care in passing the proper arguments when using this function. + .. versionchanged:: 2.0 + + ``command`` parameter is now positional-only. + Parameters ----------- command: :class:`.Command` diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 0ef814b92..a33c6cce1 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -408,13 +408,17 @@ class Command(_BaseCommand, Generic[CogT, P, T]): self.params = get_signature_parameters(function, globalns) - def add_check(self, func: Check) -> None: + def add_check(self, func: Check, /) -> None: """Adds a check to the command. This is the non-decorator interface to :func:`.check`. .. versionadded:: 1.3 + .. versionchanged:: 2.0 + + ``func`` parameter is now positional-only. + Parameters ----------- func @@ -423,7 +427,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]): self.checks.append(func) - def remove_check(self, func: Check) -> None: + def remove_check(self, func: Check, /) -> None: """Removes a check from the command. This function is idempotent and will not raise an exception @@ -431,6 +435,10 @@ class Command(_BaseCommand, Generic[CogT, P, T]): .. versionadded:: 1.3 + .. versionchanged:: 2.0 + + ``func`` parameter is now positional-only. + Parameters ----------- func @@ -1156,7 +1164,7 @@ class GroupMixin(Generic[CogT]): command.recursively_remove_all_commands() self.remove_command(command.name) - def add_command(self, command: Command[CogT, Any, Any]) -> None: + def add_command(self, command: Command[CogT, Any, Any], /) -> None: """Adds a :class:`.Command` into the internal list of commands. This is usually not called, instead the :meth:`~.GroupMixin.command` or @@ -1165,6 +1173,10 @@ class GroupMixin(Generic[CogT]): .. versionchanged:: 1.4 Raise :exc:`.CommandRegistrationError` instead of generic :exc:`.ClientException` + .. versionchanged:: 2.0 + + ``command`` parameter is now positional-only. + Parameters ----------- command: :class:`Command` @@ -1194,12 +1206,16 @@ class GroupMixin(Generic[CogT]): raise CommandRegistrationError(alias, alias_conflict=True) self.all_commands[alias] = command - def remove_command(self, name: str) -> Optional[Command[CogT, Any, Any]]: + def remove_command(self, name: str, /) -> Optional[Command[CogT, Any, Any]]: """Remove a :class:`.Command` from the internal list of commands. This could also be used as a way to remove aliases. + .. versionchanged:: 2.0 + + ``name`` parameter is now positional-only. + Parameters ----------- name: :class:`str` @@ -1247,7 +1263,7 @@ class GroupMixin(Generic[CogT]): if isinstance(command, GroupMixin): yield from command.walk_commands() - def get_command(self, name: str) -> Optional[Command[CogT, Any, Any]]: + def get_command(self, name: str, /) -> Optional[Command[CogT, Any, Any]]: """Get a :class:`.Command` from the internal list of commands. @@ -1257,6 +1273,10 @@ class GroupMixin(Generic[CogT]): the subcommand ``bar`` of the group command ``foo``. If a subcommand is not found then ``None`` is returned just as usual. + .. versionchanged:: 2.0 + + ``name`` parameter is now positional-only. + Parameters ----------- name: :class:`str` diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py index afaacbfb2..67507b010 100644 --- a/discord/ext/commands/help.py +++ b/discord/ext/commands/help.py @@ -343,12 +343,16 @@ class HelpCommand: bot.remove_command(self._command_impl.name) self._command_impl._eject_cog() - def add_check(self, func): + def add_check(self, func, /): """ Adds a check to the help command. .. versionadded:: 1.4 + .. versionchanged:: 2.0 + + ``func`` parameter is now positional-only. + Parameters ---------- func @@ -357,7 +361,7 @@ class HelpCommand: self._command_impl.add_check(func) - def remove_check(self, func): + def remove_check(self, func, /): """ Removes a check from the help command. @@ -366,6 +370,10 @@ class HelpCommand: .. versionadded:: 1.4 + .. versionchanged:: 2.0 + + ``func`` parameter is now positional-only. + Parameters ---------- func diff --git a/discord/guild.py b/discord/guild.py index 2dd7b25ff..c6606e171 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -639,6 +639,10 @@ class Guild(Hashable): This does *not* search for threads. + .. versionchanged:: 2.0 + + ``channel_id`` parameter is now positional-only. + Parameters ----------- channel_id: :class:`int` @@ -741,6 +745,10 @@ class Guild(Hashable): def get_member(self, user_id: int, /) -> Optional[Member]: """Returns a member with the given ID. + .. versionchanged:: 2.0 + + ``user_id`` parameter is now positional-only. + Parameters ----------- user_id: :class:`int` @@ -770,6 +778,10 @@ class Guild(Hashable): def get_role(self, role_id: int, /) -> Optional[Role]: """Returns a role with the given ID. + .. versionchanged:: 2.0 + + ``role_id`` parameter is now positional-only. + Parameters ----------- role_id: :class:`int` @@ -926,6 +938,10 @@ class Guild(Hashable): If no member is found, ``None`` is returned. + .. versionchanged:: 2.0 + + ``name`` parameter is now positional-only. + Parameters ----------- name: :class:`str` @@ -1696,6 +1712,10 @@ class Guild(Hashable): This method is an API call. If you have :attr:`Intents.members` and member cache enabled, consider :meth:`get_member` instead. + .. versionchanged:: 2.0 + + ``member_id`` parameter is now positional-only. + Parameters ----------- member_id: :class:`int` @@ -2208,7 +2228,7 @@ class Guild(Hashable): data = await self._state.http.create_guild_sticker(self.id, payload, file, reason) return self._state.store_sticker(self, data) - async def delete_sticker(self, sticker: Snowflake, *, reason: Optional[str] = None) -> None: + async def delete_sticker(self, sticker: Snowflake, /, *, reason: Optional[str] = None) -> None: """|coro| Deletes the custom :class:`Sticker` from the guild. @@ -2266,6 +2286,10 @@ class Guild(Hashable): This method is an API call. For general usage, consider iterating over :attr:`emojis` instead. + .. versionchanged:: 2.0 + + ``emoji_id`` parameter is now positional-only. + Parameters ------------- emoji_id: :class:`int` @@ -2338,7 +2362,7 @@ class Guild(Hashable): data = await self._state.http.create_custom_emoji(self.id, name, img, roles=role_ids, reason=reason) return self._state.store_emoji(self, data) - async def delete_emoji(self, emoji: Snowflake, *, reason: Optional[str] = None) -> None: + async def delete_emoji(self, emoji: Snowflake, /, *, reason: Optional[str] = None) -> None: """|coro| Deletes the custom :class:`Emoji` from the guild. @@ -2346,6 +2370,10 @@ class Guild(Hashable): You must have :attr:`~Permissions.manage_emojis` permission to do this. + .. versionchanged:: 2.0 + + ``emoji`` parameter is now positional-only. + Parameters ----------- emoji: :class:`abc.Snowflake` diff --git a/discord/message.py b/discord/message.py index b8abd3749..58abb2a03 100644 --- a/discord/message.py +++ b/discord/message.py @@ -1376,7 +1376,7 @@ class Message(Hashable): await self._state.http.unpin_message(self.channel.id, self.id, reason=reason) self.pinned = False - async def add_reaction(self, emoji: EmojiInputType) -> None: + async def add_reaction(self, emoji: EmojiInputType, /) -> None: """|coro| Add a reaction to the message. @@ -1387,6 +1387,10 @@ class Message(Hashable): to use this. If nobody else has reacted to the message using this emoji, the :attr:`~Permissions.add_reactions` permission is required. + .. versionchanged:: 2.0 + + ``emoji`` parameter is now positional-only. + Parameters ------------ emoji: Union[:class:`Emoji`, :class:`Reaction`, :class:`PartialEmoji`, :class:`str`] diff --git a/discord/reaction.py b/discord/reaction.py index 04eee3427..0bf885e6b 100644 --- a/discord/reaction.py +++ b/discord/reaction.py @@ -161,6 +161,10 @@ class Reaction: The ``after`` parameter must represent a member and meet the :class:`abc.Snowflake` abc. + .. versionchanged:: 2.0 + + ``limit`` and ``after`` parameters are now keyword-only. + Examples --------- diff --git a/discord/shard.py b/discord/shard.py index edbdebf4f..4a297ac65 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -374,8 +374,19 @@ class AutoShardedClient(Client): """ return [(shard_id, shard.ws.latency) for shard_id, shard in self.__shards.items()] - def get_shard(self, shard_id: int) -> Optional[ShardInfo]: - """Optional[:class:`ShardInfo`]: Gets the shard information at a given shard ID or ``None`` if not found.""" + def get_shard(self, shard_id: int, /) -> Optional[ShardInfo]: + """ + Gets the shard information at a given shard ID or ``None`` if not found. + + .. versionchanged:: 2.0 + + ``shard_id`` parameter is now positional-only. + + Returns + -------- + Optional[:class:`ShardInfo`] + Information about the shard with given ID. ``None`` if not found. + """ try: parent = self.__shards[shard_id] except KeyError: diff --git a/discord/threads.py b/discord/threads.py index 57db26a7e..b478b4f29 100644 --- a/discord/threads.py +++ b/discord/threads.py @@ -364,7 +364,7 @@ class Thread(Messageable, Hashable): raise ClientException('Parent channel not found') return parent.permissions_for(obj) - async def delete_messages(self, messages: Iterable[Snowflake]) -> None: + async def delete_messages(self, messages: Iterable[Snowflake], /) -> None: """|coro| Deletes a list of messages. This is similar to :meth:`Message.delete` @@ -631,7 +631,7 @@ class Thread(Messageable, Hashable): """ await self._state.http.leave_thread(self.id) - async def add_user(self, user: Snowflake): + async def add_user(self, user: Snowflake, /): """|coro| Adds a user to this thread. @@ -655,7 +655,7 @@ class Thread(Messageable, Hashable): """ await self._state.http.add_user_to_thread(self.id, user.id) - async def remove_user(self, user: Snowflake): + async def remove_user(self, user: Snowflake, /): """|coro| Removes a user from this thread. diff --git a/discord/utils.py b/discord/utils.py index 36d881f05..867401f92 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -276,6 +276,11 @@ def oauth_url( """A helper function that returns the OAuth2 URL for inviting the bot into guilds. + .. versionchanged:: 2.0 + + ``permissions``, ``guild``, ``redirect_uri``, and ``scopes`` parameters + are now keyword-only. + Parameters ----------- client_id: Union[:class:`int`, :class:`str`] diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 0f23527b7..d63d16cc4 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -1422,7 +1422,7 @@ class Webhook(BaseWebhook): return msg - async def fetch_message(self, id: int) -> WebhookMessage: + async def fetch_message(self, id: int, /) -> WebhookMessage: """|coro| Retrieves a single :class:`~discord.WebhookMessage` owned by this webhook. @@ -1583,6 +1583,10 @@ class Webhook(BaseWebhook): .. versionadded:: 1.6 + .. versionchanged:: 2.0 + + ``message_id`` parameter is now positional-only. + Parameters ------------ message_id: :class:`int`