Browse Source

Rework Template.edit to use MISSING sentinel

pull/7139/head
Rapptz 4 years ago
parent
commit
b1a355394f
  1. 27
      discord/template.py

27
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:

Loading…
Cancel
Save