From b1a355394f80c94e2e724b28317b1521a96b2674 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 29 Jun 2021 21:33:57 -0400 Subject: [PATCH] Rework Template.edit to use MISSING sentinel --- discord/template.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/discord/template.py b/discord/template.py index 2eaa69277..825ad3cc4 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: