Rework Template.edit to use MISSING sentinel
This commit is contained in:
parent
39a674ddee
commit
b1a355394f
@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Optional, TYPE_CHECKING, overload
|
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 .enums import VoiceRegion
|
||||||
from .guild import Guild
|
from .guild import Guild
|
||||||
|
|
||||||
@ -221,20 +221,12 @@ class Template:
|
|||||||
data = await self._state.http.sync_template(self.source_guild.id, self.code)
|
data = await self._state.http.sync_template(self.source_guild.id, self.code)
|
||||||
self._store(data)
|
self._store(data)
|
||||||
|
|
||||||
@overload
|
|
||||||
async def edit(
|
async def edit(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
name: Optional[str] = ...,
|
name: str = MISSING,
|
||||||
description: Optional[str] = ...,
|
description: Optional[str] = MISSING,
|
||||||
) -> None:
|
) -> None:
|
||||||
...
|
|
||||||
|
|
||||||
@overload
|
|
||||||
async def edit(self) -> None:
|
|
||||||
...
|
|
||||||
|
|
||||||
async def edit(self, **kwargs) -> None:
|
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Edit the template metadata.
|
Edit the template metadata.
|
||||||
@ -246,10 +238,10 @@ class Template:
|
|||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
------------
|
------------
|
||||||
name: Optional[:class:`str`]
|
name: :class:`str`
|
||||||
The template's new name.
|
The template's new name.
|
||||||
description: Optional[:class:`str`]
|
description: Optional[:class:`str`]
|
||||||
The template's description.
|
The template's new description.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
@ -260,7 +252,14 @@ class Template:
|
|||||||
NotFound
|
NotFound
|
||||||
This template does not exist.
|
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)
|
self._store(data)
|
||||||
|
|
||||||
async def delete(self) -> None:
|
async def delete(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user