Fix Webhook return types
Also add positional only arguments where applicable
This commit is contained in:
parent
e7821be4aa
commit
059ec161f8
@ -933,12 +933,12 @@ class Webhook(BaseWebhook):
|
||||
return f'<Webhook id={self.id!r}>'
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
def url(self) -> str:
|
||||
""":class:`str` : Returns the webhook's url."""
|
||||
return f'https://discord.com/api/webhooks/{self.id}/{self.token}'
|
||||
|
||||
@classmethod
|
||||
def partial(cls, id: int, token: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None):
|
||||
def partial(cls, id: int, token: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None) -> Webhook:
|
||||
"""Creates a partial :class:`Webhook`.
|
||||
|
||||
Parameters
|
||||
@ -974,7 +974,7 @@ class Webhook(BaseWebhook):
|
||||
return cls(data, session, token=bot_token)
|
||||
|
||||
@classmethod
|
||||
def from_url(cls, url: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None):
|
||||
def from_url(cls, url: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None) -> Webhook:
|
||||
"""Creates a partial :class:`Webhook` from a webhook URL.
|
||||
|
||||
Parameters
|
||||
@ -1013,7 +1013,7 @@ class Webhook(BaseWebhook):
|
||||
return cls(data, session, token=bot_token) # type: ignore
|
||||
|
||||
@classmethod
|
||||
def _as_follower(cls, data, *, channel, user):
|
||||
def _as_follower(cls, data, *, channel, user) -> Webhook:
|
||||
name = f"{channel.guild} #{channel}"
|
||||
feed: WebhookPayload = {
|
||||
'id': data['webhook_id'],
|
||||
@ -1029,7 +1029,7 @@ class Webhook(BaseWebhook):
|
||||
return cls(feed, session=session, state=state, token=state.http.token)
|
||||
|
||||
@classmethod
|
||||
def from_state(cls, data, state):
|
||||
def from_state(cls, data, state) -> Webhook:
|
||||
session = state.http._HTTPClient__session
|
||||
return cls(data, session=session, state=state, token=state.http.token)
|
||||
|
||||
@ -1555,7 +1555,7 @@ class Webhook(BaseWebhook):
|
||||
self._state.store_view(view, message_id)
|
||||
return message
|
||||
|
||||
async def delete_message(self, message_id: int):
|
||||
async def delete_message(self, message_id: int, /) -> None:
|
||||
"""|coro|
|
||||
|
||||
Deletes a message owned by this webhook.
|
||||
|
@ -522,12 +522,12 @@ class SyncWebhook(BaseWebhook):
|
||||
return f'<Webhook id={self.id!r}>'
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
def url(self) -> str:
|
||||
""":class:`str` : Returns the webhook's url."""
|
||||
return f'https://discord.com/api/webhooks/{self.id}/{self.token}'
|
||||
|
||||
@classmethod
|
||||
def partial(cls, id: int, token: str, *, session: Session = MISSING, bot_token: Optional[str] = None):
|
||||
def partial(cls, id: int, token: str, *, session: Session = MISSING, bot_token: Optional[str] = None) -> SyncWebhook:
|
||||
"""Creates a partial :class:`Webhook`.
|
||||
|
||||
Parameters
|
||||
@ -566,7 +566,7 @@ class SyncWebhook(BaseWebhook):
|
||||
return cls(data, session, token=bot_token)
|
||||
|
||||
@classmethod
|
||||
def from_url(cls, url: str, *, session: Session = MISSING, bot_token: Optional[str] = None):
|
||||
def from_url(cls, url: str, *, session: Session = MISSING, bot_token: Optional[str] = None) -> SyncWebhook:
|
||||
"""Creates a partial :class:`Webhook` from a webhook URL.
|
||||
|
||||
Parameters
|
||||
@ -650,7 +650,7 @@ class SyncWebhook(BaseWebhook):
|
||||
|
||||
return SyncWebhook(data, self.session, token=self.auth_token, state=self._state)
|
||||
|
||||
def delete(self, *, reason: Optional[str] = None, prefer_auth: bool = True):
|
||||
def delete(self, *, reason: Optional[str] = None, prefer_auth: bool = True) -> None:
|
||||
"""Deletes this Webhook.
|
||||
|
||||
Parameters
|
||||
@ -918,7 +918,7 @@ class SyncWebhook(BaseWebhook):
|
||||
if wait:
|
||||
return self._create_message(data)
|
||||
|
||||
def fetch_message(self, id: int) -> SyncWebhookMessage:
|
||||
def fetch_message(self, id: int, /) -> SyncWebhookMessage:
|
||||
"""Retrieves a single :class:`~discord.SyncWebhookMessage` owned by this webhook.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
@ -1034,7 +1034,7 @@ class SyncWebhook(BaseWebhook):
|
||||
)
|
||||
return self._create_message(data)
|
||||
|
||||
def delete_message(self, message_id: int):
|
||||
def delete_message(self, message_id: int, /) -> None:
|
||||
"""Deletes a message owned by this webhook.
|
||||
|
||||
This is a lower level interface to :meth:`WebhookMessage.delete` in case
|
||||
|
Loading…
x
Reference in New Issue
Block a user