mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
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}>'
|
return f'<Webhook id={self.id!r}>'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self):
|
def url(self) -> str:
|
||||||
""":class:`str` : Returns the webhook's url."""
|
""":class:`str` : Returns the webhook's url."""
|
||||||
return f'https://discord.com/api/webhooks/{self.id}/{self.token}'
|
return f'https://discord.com/api/webhooks/{self.id}/{self.token}'
|
||||||
|
|
||||||
@classmethod
|
@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`.
|
"""Creates a partial :class:`Webhook`.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -974,7 +974,7 @@ class Webhook(BaseWebhook):
|
|||||||
return cls(data, session, token=bot_token)
|
return cls(data, session, token=bot_token)
|
||||||
|
|
||||||
@classmethod
|
@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.
|
"""Creates a partial :class:`Webhook` from a webhook URL.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -1013,7 +1013,7 @@ class Webhook(BaseWebhook):
|
|||||||
return cls(data, session, token=bot_token) # type: ignore
|
return cls(data, session, token=bot_token) # type: ignore
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _as_follower(cls, data, *, channel, user):
|
def _as_follower(cls, data, *, channel, user) -> Webhook:
|
||||||
name = f"{channel.guild} #{channel}"
|
name = f"{channel.guild} #{channel}"
|
||||||
feed: WebhookPayload = {
|
feed: WebhookPayload = {
|
||||||
'id': data['webhook_id'],
|
'id': data['webhook_id'],
|
||||||
@ -1029,7 +1029,7 @@ class Webhook(BaseWebhook):
|
|||||||
return cls(feed, session=session, state=state, token=state.http.token)
|
return cls(feed, session=session, state=state, token=state.http.token)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_state(cls, data, state):
|
def from_state(cls, data, state) -> Webhook:
|
||||||
session = state.http._HTTPClient__session
|
session = state.http._HTTPClient__session
|
||||||
return cls(data, session=session, state=state, token=state.http.token)
|
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)
|
self._state.store_view(view, message_id)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
async def delete_message(self, message_id: int):
|
async def delete_message(self, message_id: int, /) -> None:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Deletes a message owned by this webhook.
|
Deletes a message owned by this webhook.
|
||||||
|
@ -522,12 +522,12 @@ class SyncWebhook(BaseWebhook):
|
|||||||
return f'<Webhook id={self.id!r}>'
|
return f'<Webhook id={self.id!r}>'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self):
|
def url(self) -> str:
|
||||||
""":class:`str` : Returns the webhook's url."""
|
""":class:`str` : Returns the webhook's url."""
|
||||||
return f'https://discord.com/api/webhooks/{self.id}/{self.token}'
|
return f'https://discord.com/api/webhooks/{self.id}/{self.token}'
|
||||||
|
|
||||||
@classmethod
|
@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`.
|
"""Creates a partial :class:`Webhook`.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -566,7 +566,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
return cls(data, session, token=bot_token)
|
return cls(data, session, token=bot_token)
|
||||||
|
|
||||||
@classmethod
|
@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.
|
"""Creates a partial :class:`Webhook` from a webhook URL.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -650,7 +650,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
|
|
||||||
return SyncWebhook(data, self.session, token=self.auth_token, state=self._state)
|
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.
|
"""Deletes this Webhook.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -918,7 +918,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
if wait:
|
if wait:
|
||||||
return self._create_message(data)
|
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.
|
"""Retrieves a single :class:`~discord.SyncWebhookMessage` owned by this webhook.
|
||||||
|
|
||||||
.. versionadded:: 2.0
|
.. versionadded:: 2.0
|
||||||
@ -1034,7 +1034,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
)
|
)
|
||||||
return self._create_message(data)
|
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.
|
"""Deletes a message owned by this webhook.
|
||||||
|
|
||||||
This is a lower level interface to :meth:`WebhookMessage.delete` in case
|
This is a lower level interface to :meth:`WebhookMessage.delete` in case
|
||||||
|
Loading…
x
Reference in New Issue
Block a user