diff options
| author | Rapptz <[email protected]> | 2021-06-29 21:33:57 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-06-29 21:33:57 -0400 |
| commit | b1a355394f80c94e2e724b28317b1521a96b2674 (patch) | |
| tree | 7ec68333d2d44acf0fb95eafe5619433711b7692 /discord/template.py | |
| parent | Fix typing of ApplicationCommandInteractionDataOption (diff) | |
| download | discord.py-b1a355394f80c94e2e724b28317b1521a96b2674.tar.xz discord.py-b1a355394f80c94e2e724b28317b1521a96b2674.zip | |
Rework Template.edit to use MISSING sentinel
Diffstat (limited to 'discord/template.py')
| -rw-r--r-- | discord/template.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/discord/template.py b/discord/template.py index 2eaa6927..825ad3cc 100644 --- a/discord/template.py +++ b/discord/template.py @@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE. from __future__ import annotations from typing import Any, Optional, TYPE_CHECKING, overload -from .utils import parse_time, _get_as_snowflake, _bytes_to_base64_data +from .utils import parse_time, _get_as_snowflake, _bytes_to_base64_data, MISSING from .enums import VoiceRegion from .guild import Guild @@ -221,20 +221,12 @@ class Template: data = await self._state.http.sync_template(self.source_guild.id, self.code) self._store(data) - @overload async def edit( self, *, - name: Optional[str] = ..., - description: Optional[str] = ..., + name: str = MISSING, + description: Optional[str] = MISSING, ) -> None: - ... - - @overload - async def edit(self) -> None: - ... - - async def edit(self, **kwargs) -> None: """|coro| Edit the template metadata. @@ -246,10 +238,10 @@ class Template: Parameters ------------ - name: Optional[:class:`str`] + name: :class:`str` The template's new name. description: Optional[:class:`str`] - The template's description. + The template's new description. Raises ------- @@ -260,7 +252,14 @@ class Template: NotFound This template does not exist. """ - data = await self._state.http.edit_template(self.source_guild.id, self.code, kwargs) + payload = {} + + if name is not MISSING: + payload['name'] = name + if description is not MISSING: + payload['description'] = description + + data = await self._state.http.edit_template(self.source_guild.id, self.code, payload) self._store(data) async def delete(self) -> None: |