Allow Webhook to be hashable and comparable
This commit is contained in:
parent
c3bca7ec73
commit
de556b01d1
@ -36,6 +36,7 @@ from .errors import InvalidArgument, HTTPException, Forbidden, NotFound
|
|||||||
from .enums import try_enum, WebhookType
|
from .enums import try_enum, WebhookType
|
||||||
from .user import BaseUser, User
|
from .user import BaseUser, User
|
||||||
from .asset import Asset
|
from .asset import Asset
|
||||||
|
from .mixins import Hashable
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'WebhookAdapter',
|
'WebhookAdapter',
|
||||||
@ -359,7 +360,7 @@ class _PartialWebhookState:
|
|||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
raise AttributeError('PartialWebhookState does not support {0!r}.'.format(attr))
|
raise AttributeError('PartialWebhookState does not support {0!r}.'.format(attr))
|
||||||
|
|
||||||
class Webhook:
|
class Webhook(Hashable):
|
||||||
"""Represents a Discord webhook.
|
"""Represents a Discord webhook.
|
||||||
|
|
||||||
Webhooks are a form to send messages to channels in Discord without a
|
Webhooks are a form to send messages to channels in Discord without a
|
||||||
@ -400,6 +401,23 @@ class Webhook:
|
|||||||
webhook = Webhook.partial(123456, 'abcdefg', adapter=RequestsWebhookAdapter())
|
webhook = Webhook.partial(123456, 'abcdefg', adapter=RequestsWebhookAdapter())
|
||||||
webhook.send('Hello World', username='Foo')
|
webhook.send('Hello World', username='Foo')
|
||||||
|
|
||||||
|
.. container:: operations
|
||||||
|
|
||||||
|
.. describe:: x == y
|
||||||
|
|
||||||
|
Checks if two webhooks are equal.
|
||||||
|
|
||||||
|
.. describe:: x != y
|
||||||
|
|
||||||
|
Checks if two webhooks are not equal.
|
||||||
|
|
||||||
|
.. describe:: hash(x)
|
||||||
|
|
||||||
|
Returns the webhooks's hash.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.4
|
||||||
|
Webhooks are now comparable and hashable.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
------------
|
------------
|
||||||
id: :class:`int`
|
id: :class:`int`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user