Compare commits
2 Commits
paris-ci/p
...
wasi-maste
Author | SHA1 | Date | |
---|---|---|---|
30da1159e1 | |||
8ec591e46b |
@ -313,11 +313,10 @@ class Asset(AssetMixin):
|
||||
if self._animated:
|
||||
if format not in VALID_ASSET_FORMATS:
|
||||
raise InvalidArgument(f'format must be one of {VALID_ASSET_FORMATS}')
|
||||
url = url.with_path(f'{path}.{format}')
|
||||
elif static_format is MISSING:
|
||||
else:
|
||||
if format not in VALID_STATIC_FORMATS:
|
||||
raise InvalidArgument(f'format must be one of {VALID_STATIC_FORMATS}')
|
||||
url = url.with_path(f'{path}.{format}')
|
||||
url = url.with_path(f'{path}.{format}')
|
||||
|
||||
if static_format is not MISSING and not self._animated:
|
||||
if static_format not in VALID_STATIC_FORMATS:
|
||||
|
@ -330,10 +330,6 @@ class AuditLogEntry(Hashable):
|
||||
|
||||
Returns the entry's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the entry's ID.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
Audit log entries are now comparable and hashable.
|
||||
|
||||
|
@ -45,7 +45,7 @@ import datetime
|
||||
|
||||
import discord.abc
|
||||
from .permissions import PermissionOverwrite, Permissions
|
||||
from .enums import ChannelType, StagePrivacyLevel, try_enum, VoiceRegion, VideoQualityMode
|
||||
from .enums import ChannelType, StagePrivacyLevel, try_enum, VoiceRegion, VideoQualityMode, PartyType
|
||||
from .mixins import Hashable
|
||||
from .object import Object
|
||||
from . import utils
|
||||
@ -115,10 +115,6 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
|
||||
Returns the channel's name.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the channel's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
name: :class:`str`
|
||||
@ -1041,6 +1037,38 @@ class VoiceChannel(VocalGuildChannel):
|
||||
# the payload will always be the proper channel payload
|
||||
return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore
|
||||
|
||||
async def create_party(self, application_id: PartyType, max_age: int = 86400 , max_uses: int = 0):
|
||||
"""|coro|
|
||||
Creates a party in this voice channel.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Parameters
|
||||
----------
|
||||
application_id : :class:`PartyType`
|
||||
The id of the application the party belongs to. currently any of
|
||||
``PartyType.youtube``, ``PartyType.poker``, ``PartyType.betrayal``, ``PartyType.fishing``, ``PartyType.chess``.
|
||||
max_age : :class:`int`, optional
|
||||
Duration in seconds after which the invite expires, by default 1 day.
|
||||
max_uses : :class:`int`, optional
|
||||
maximum number of times this invite can be used, by default unlimited.
|
||||
|
||||
Raises
|
||||
-------
|
||||
Forbidden
|
||||
You do not have permissions to create a party.
|
||||
HTTPException
|
||||
Party creation failed.
|
||||
|
||||
Returns
|
||||
--------
|
||||
:class:`Party`
|
||||
The created party.
|
||||
"""
|
||||
return Party(await self._state.http.create_party(self.id, application_id.value, max_age=max_age, max_uses=max_uses))
|
||||
|
||||
|
||||
|
||||
|
||||
class StageChannel(VocalGuildChannel):
|
||||
"""Represents a Discord guild stage channel.
|
||||
@ -1338,10 +1366,6 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
|
||||
|
||||
Returns the category's name.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the category's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
name: :class:`str`
|
||||
@ -1564,10 +1588,6 @@ class StoreChannel(discord.abc.GuildChannel, Hashable):
|
||||
|
||||
Returns the channel's name.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the channel's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
name: :class:`str`
|
||||
@ -1740,10 +1760,6 @@ class DMChannel(discord.abc.Messageable, Hashable):
|
||||
|
||||
Returns a string representation of the channel
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the channel's ID.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
recipient: Optional[:class:`User`]
|
||||
@ -1870,10 +1886,6 @@ class GroupChannel(discord.abc.Messageable, Hashable):
|
||||
|
||||
Returns a string representation of the channel
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the channel's ID.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
recipients: List[:class:`User`]
|
||||
@ -2020,10 +2032,6 @@ class PartialMessageable(discord.abc.Messageable, Hashable):
|
||||
|
||||
Returns the partial messageable's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the messageable's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
id: :class:`int`
|
||||
@ -2062,6 +2070,76 @@ class PartialMessageable(discord.abc.Messageable, Hashable):
|
||||
|
||||
return PartialMessage(channel=self, id=message_id)
|
||||
|
||||
class Party:
|
||||
"""Represents a party in a voice channel.
|
||||
|
||||
.. container:: operations
|
||||
|
||||
.. describe:: x == y
|
||||
|
||||
Checks if two party are equal.
|
||||
|
||||
.. describe:: x != y
|
||||
|
||||
Checks if two party are not equal.
|
||||
|
||||
.. describe:: hash(x)
|
||||
|
||||
Returns the party hash.
|
||||
|
||||
.. describe:: str(x)
|
||||
|
||||
Returns the party URL.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
code: :class:`str`
|
||||
The URL fragment used for the party.
|
||||
uses: :class:`int`
|
||||
How many times the invite has been used.
|
||||
max_uses: :class:`int`
|
||||
How many times the invite can be used.
|
||||
A value of ``0`` indicates that it has unlimited uses.
|
||||
max_age: :class:`int`
|
||||
How long before the party expires in seconds.
|
||||
A value of ``0`` indicates that it doesn't expire.
|
||||
temporary: :class:`bool`
|
||||
Indicates that the invite grants temporary membership.
|
||||
If ``True``, members who joined via this invite will be kicked upon disconnect.
|
||||
created_at: :class:`datetime.datetime`
|
||||
An aware UTC datetime object denoting the time the invite was created.
|
||||
|
||||
Note
|
||||
----
|
||||
Parties are still in BETA so there are some limitations.
|
||||
Currently this BETA feature is only supported on web and updated PC app versions of Discord and is not supported on mobile.
|
||||
First someone has to to click the blue link itself and not the join button, then everyone else can click the join button normally.
|
||||
"""
|
||||
|
||||
__slots__ = ('code', 'uses', 'max_uses', 'max_age', 'temporary', 'created_at')
|
||||
|
||||
def __init__(self, data):
|
||||
self.code: str = data['code']
|
||||
self.uses: Optional[int] = data.get('uses')
|
||||
self.max_uses: Optional[int] = data.get('max_uses')
|
||||
self.max_age: Optional[int] = data.get('max_age')
|
||||
self.temporary: Optional[bool] = data.get('temporary')
|
||||
self.created_at: Optional[datetime.datetime] = utils.parse_time(data.get('created_at'))
|
||||
# TODO: add more fields here such as guild. raw data: https://mystb.in/AdvertisersExperiencesMothers.json
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Party code={self.code}>'
|
||||
|
||||
def __str__(self):
|
||||
return f'https://discord.gg/{self.code}'
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash(self.code)
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, Party) and self.code == other.code
|
||||
|
||||
|
||||
|
||||
def _guild_channel_factory(channel_type: int):
|
||||
value = try_enum(ChannelType, channel_type)
|
||||
|
@ -142,6 +142,7 @@ class Client:
|
||||
intents: :class:`Intents`
|
||||
The intents that you want to enable for the session. This is a way of
|
||||
disabling and enabling certain gateway events from triggering and being sent.
|
||||
If not given, defaults to a regularly constructed :class:`Intents` class.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
member_cache_flags: :class:`MemberCacheFlags`
|
||||
@ -202,12 +203,9 @@ class Client:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
intents: Intents,
|
||||
loop: Optional[asyncio.AbstractEventLoop] = None,
|
||||
**options: Any,
|
||||
):
|
||||
options["intents"] = intents
|
||||
|
||||
# self.ws is set in the connect method
|
||||
self.ws: DiscordWebSocket = None # type: ignore
|
||||
self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop() if loop is None else loop
|
||||
|
@ -324,15 +324,6 @@ class Colour:
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
return cls(0xFEE75C)
|
||||
|
||||
@classmethod
|
||||
def dark_blurple(cls: Type[CT]) -> CT:
|
||||
"""A factory method that returns a :class:`Colour` with a value of ``0x4E5D94``.
|
||||
This is the original Dark Blurple branding.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
return cls(0x4E5D94)
|
||||
|
||||
|
||||
Color = Colour
|
||||
|
@ -72,36 +72,30 @@ if TYPE_CHECKING:
|
||||
T = TypeVar('T')
|
||||
MaybeEmpty = Union[T, _EmptyEmbed]
|
||||
|
||||
|
||||
class _EmbedFooterProxy(Protocol):
|
||||
text: MaybeEmpty[str]
|
||||
icon_url: MaybeEmpty[str]
|
||||
|
||||
|
||||
class _EmbedFieldProxy(Protocol):
|
||||
name: MaybeEmpty[str]
|
||||
value: MaybeEmpty[str]
|
||||
inline: bool
|
||||
|
||||
|
||||
class _EmbedMediaProxy(Protocol):
|
||||
url: MaybeEmpty[str]
|
||||
proxy_url: MaybeEmpty[str]
|
||||
height: MaybeEmpty[int]
|
||||
width: MaybeEmpty[int]
|
||||
|
||||
|
||||
class _EmbedVideoProxy(Protocol):
|
||||
url: MaybeEmpty[str]
|
||||
height: MaybeEmpty[int]
|
||||
width: MaybeEmpty[int]
|
||||
|
||||
|
||||
class _EmbedProviderProxy(Protocol):
|
||||
name: MaybeEmpty[str]
|
||||
url: MaybeEmpty[str]
|
||||
|
||||
|
||||
class _EmbedAuthorProxy(Protocol):
|
||||
name: MaybeEmpty[str]
|
||||
url: MaybeEmpty[str]
|
||||
@ -181,15 +175,15 @@ class Embed:
|
||||
Empty: Final = EmptyEmbed
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
colour: Union[int, Colour, _EmptyEmbed] = EmptyEmbed,
|
||||
color: Union[int, Colour, _EmptyEmbed] = EmptyEmbed,
|
||||
title: MaybeEmpty[Any] = EmptyEmbed,
|
||||
type: EmbedType = 'rich',
|
||||
url: MaybeEmpty[Any] = EmptyEmbed,
|
||||
description: MaybeEmpty[Any] = EmptyEmbed,
|
||||
timestamp: datetime.datetime = None,
|
||||
self,
|
||||
*,
|
||||
colour: Union[int, Colour, _EmptyEmbed] = EmptyEmbed,
|
||||
color: Union[int, Colour, _EmptyEmbed] = EmptyEmbed,
|
||||
title: MaybeEmpty[Any] = EmptyEmbed,
|
||||
type: EmbedType = 'rich',
|
||||
url: MaybeEmpty[Any] = EmptyEmbed,
|
||||
description: MaybeEmpty[Any] = EmptyEmbed,
|
||||
timestamp: datetime.datetime = None,
|
||||
):
|
||||
|
||||
self.colour = colour if colour is not EmptyEmbed else color
|
||||
@ -372,7 +366,7 @@ class Embed:
|
||||
self._footer['icon_url'] = str(icon_url)
|
||||
|
||||
return self
|
||||
|
||||
|
||||
def remove_footer(self: E) -> E:
|
||||
"""Clears embed's footer information.
|
||||
|
||||
@ -387,7 +381,7 @@ class Embed:
|
||||
pass
|
||||
|
||||
return self
|
||||
|
||||
|
||||
@property
|
||||
def image(self) -> _EmbedMediaProxy:
|
||||
"""Returns an ``EmbedProxy`` denoting the image contents.
|
||||
@ -403,19 +397,6 @@ class Embed:
|
||||
"""
|
||||
return EmbedProxy(getattr(self, '_image', {})) # type: ignore
|
||||
|
||||
@image.setter
|
||||
def image(self: E, *, url: Any):
|
||||
self._image = {
|
||||
'url': str(url),
|
||||
}
|
||||
|
||||
@image.deleter
|
||||
def image(self: E):
|
||||
try:
|
||||
del self._image
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def set_image(self: E, *, url: MaybeEmpty[Any]) -> E:
|
||||
"""Sets the image for the embed content.
|
||||
|
||||
@ -432,9 +413,14 @@ class Embed:
|
||||
"""
|
||||
|
||||
if url is EmptyEmbed:
|
||||
del self.image
|
||||
try:
|
||||
del self._image
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
self.image = url
|
||||
self._image = {
|
||||
'url': str(url),
|
||||
}
|
||||
|
||||
return self
|
||||
|
||||
@ -453,25 +439,7 @@ class Embed:
|
||||
"""
|
||||
return EmbedProxy(getattr(self, '_thumbnail', {})) # type: ignore
|
||||
|
||||
@thumbnail.setter
|
||||
def thumbnail(self: E, *, url: Any):
|
||||
"""Sets the thumbnail for the embed content.
|
||||
"""
|
||||
|
||||
self._thumbnail = {
|
||||
'url': str(url),
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@thumbnail.deleter
|
||||
def thumbnail(self):
|
||||
try:
|
||||
del self.thumbnail
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def set_thumbnail(self: E, *, url: MaybeEmpty[Any]):
|
||||
def set_thumbnail(self: E, *, url: MaybeEmpty[Any]) -> E:
|
||||
"""Sets the thumbnail for the embed content.
|
||||
|
||||
This function returns the class instance to allow for fluent-style
|
||||
@ -485,10 +453,16 @@ class Embed:
|
||||
url: :class:`str`
|
||||
The source URL for the thumbnail. Only HTTP(S) is supported.
|
||||
"""
|
||||
|
||||
if url is EmptyEmbed:
|
||||
del self.thumbnail
|
||||
try:
|
||||
del self._thumbnail
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
self.thumbnail = url
|
||||
self._thumbnail = {
|
||||
'url': str(url),
|
||||
}
|
||||
|
||||
return self
|
||||
|
||||
|
@ -72,10 +72,6 @@ class Emoji(_EmojiTag, AssetMixin):
|
||||
|
||||
Returns the emoji rendered for discord.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the emoji ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
name: :class:`str`
|
||||
@ -141,9 +137,6 @@ class Emoji(_EmojiTag, AssetMixin):
|
||||
return f'<a:{self.name}:{self.id}>'
|
||||
return f'<:{self.name}:{self.id}>'
|
||||
|
||||
def __int__(self) -> int:
|
||||
return self.id
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<Emoji id={self.id} name={self.name!r} animated={self.animated} managed={self.managed}>'
|
||||
|
||||
|
@ -30,6 +30,7 @@ __all__ = (
|
||||
'Enum',
|
||||
'ChannelType',
|
||||
'MessageType',
|
||||
'PartyType',
|
||||
'VoiceRegion',
|
||||
'SpeakingState',
|
||||
'VerificationLevel',
|
||||
@ -214,6 +215,14 @@ class MessageType(Enum):
|
||||
guild_invite_reminder = 22
|
||||
|
||||
|
||||
class PartyType(Enum):
|
||||
youtube = 755600276941176913
|
||||
poker = 755827207812677713
|
||||
betrayal = 773336526917861400
|
||||
fishing = 814288819477020702
|
||||
chess = 832012774040141894
|
||||
|
||||
|
||||
class VoiceRegion(Enum):
|
||||
us_west = 'us-west'
|
||||
us_east = 'us-east'
|
||||
|
@ -120,8 +120,8 @@ class _DefaultRepr:
|
||||
_default = _DefaultRepr()
|
||||
|
||||
class BotBase(GroupMixin):
|
||||
def __init__(self, command_prefix, help_command=_default, description=None, *, intents: discord.Intents, **options):
|
||||
super().__init__(**options, intents=intents)
|
||||
def __init__(self, command_prefix, help_command=_default, description=None, **options):
|
||||
super().__init__(**options)
|
||||
self.command_prefix = command_prefix
|
||||
self.extra_events: Dict[str, List[CoroFunc]] = {}
|
||||
self.__cogs: Dict[str, Cog] = {}
|
||||
|
@ -480,6 +480,16 @@ class Intents(BaseFlags):
|
||||
self.value = self.DEFAULT_VALUE
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def default(cls: Type[Intents]) -> Intents:
|
||||
"""A factory method that creates a :class:`Intents` with everything enabled
|
||||
except :attr:`presences` and :attr:`members`.
|
||||
"""
|
||||
self = cls.all()
|
||||
self.presences = False
|
||||
self.members = False
|
||||
return self
|
||||
|
||||
@flag_value
|
||||
def guilds(self):
|
||||
""":class:`bool`: Whether guild related events are enabled.
|
||||
|
@ -140,10 +140,6 @@ class Guild(Hashable):
|
||||
|
||||
Returns the guild's name.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the guild's ID.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
name: :class:`str`
|
||||
@ -742,16 +738,12 @@ class Guild(Hashable):
|
||||
|
||||
@property
|
||||
def humans(self) -> List[Member]:
|
||||
"""List[:class:`Member`]: A list of human members that belong to this guild.
|
||||
|
||||
.. versionadded:: 2.0 """
|
||||
"""List[:class:`Member`]: A list of human members that belong to this guild."""
|
||||
return [member for member in self.members if not member.bot]
|
||||
|
||||
@property
|
||||
def bots(self) -> List[Member]:
|
||||
"""List[:class:`Member`]: A list of bots that belong to this guild.
|
||||
|
||||
.. versionadded:: 2.0 """
|
||||
"""List[:class:`Member`]: A list of bots that belong to this guild."""
|
||||
return [member for member in self.members if member.bot]
|
||||
|
||||
def get_member(self, user_id: int, /) -> Optional[Member]:
|
||||
|
@ -880,6 +880,24 @@ class HTTPClient:
|
||||
) -> Response[None]:
|
||||
return self.request(Route('DELETE', '/channels/{channel_id}', channel_id=channel_id), reason=reason)
|
||||
|
||||
def create_party(
|
||||
self,
|
||||
channel_id: Snowflake,
|
||||
application_id: Snowflake,
|
||||
max_age: int,
|
||||
max_uses: int,
|
||||
) -> Response[channel.Party]:
|
||||
payload = {
|
||||
'max_age': max_age,
|
||||
'max_uses': max_uses,
|
||||
'target_application_id': application_id,
|
||||
'target_type': 2,
|
||||
'temporary': False,
|
||||
'validate': None
|
||||
}
|
||||
return self.request(Route("POST", "/channels/{channel_id}/invites", channel_id=channel_id), json=payload)
|
||||
|
||||
|
||||
# Thread management
|
||||
|
||||
def start_thread_with_message(
|
||||
|
@ -230,7 +230,6 @@ class Invite(Hashable):
|
||||
|
||||
Returns the invite URL.
|
||||
|
||||
|
||||
The following table illustrates what methods will obtain the attributes:
|
||||
|
||||
+------------------------------------+------------------------------------------------------------+
|
||||
@ -434,9 +433,6 @@ class Invite(Hashable):
|
||||
def __str__(self) -> str:
|
||||
return self.url
|
||||
|
||||
def __int__(self) -> int:
|
||||
return 0 # To keep the object compatible with the hashable abc.
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f'<Invite code={self.code!r} guild={self.guild!r} '
|
||||
|
@ -226,10 +226,6 @@ class Member(discord.abc.Messageable, _UserTag):
|
||||
|
||||
Returns the member's name with the discriminator.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the user's ID.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
joined_at: Optional[:class:`datetime.datetime`]
|
||||
@ -304,9 +300,6 @@ class Member(discord.abc.Messageable, _UserTag):
|
||||
def __str__(self) -> str:
|
||||
return str(self._user)
|
||||
|
||||
def __int__(self) -> int:
|
||||
return self.id
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f'<Member id={self._user.id} name={self._user.name!r} discriminator={self._user.discriminator!r}'
|
||||
|
@ -125,10 +125,6 @@ class Attachment(Hashable):
|
||||
|
||||
Returns the hash of the attachment.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the attachment's ID.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
Attachment can now be casted to :class:`str` and is hashable.
|
||||
|
||||
@ -507,14 +503,6 @@ class Message(Hashable):
|
||||
|
||||
Returns the message's hash.
|
||||
|
||||
.. describe:: str(x)
|
||||
|
||||
Returns the message's content.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the message's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
tts: :class:`bool`
|
||||
@ -724,10 +712,6 @@ class Message(Hashable):
|
||||
f'<{name} id={self.id} channel={self.channel!r} type={self.type!r} author={self.author!r} flags={self.flags!r}>'
|
||||
)
|
||||
|
||||
|
||||
def __str__(self) -> Optional[str]:
|
||||
return self.content
|
||||
|
||||
def _try_patch(self, data, key, transform=None) -> None:
|
||||
try:
|
||||
value = data[key]
|
||||
@ -1650,10 +1634,6 @@ class PartialMessage(Hashable):
|
||||
|
||||
Returns the partial message's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the partial message's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
channel: Union[:class:`TextChannel`, :class:`Thread`, :class:`DMChannel`]
|
||||
|
@ -43,8 +43,5 @@ class EqualityComparable:
|
||||
class Hashable(EqualityComparable):
|
||||
__slots__ = ()
|
||||
|
||||
def __int__(self) -> int:
|
||||
return self.id
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return self.id >> 22
|
||||
|
@ -69,10 +69,6 @@ class Object(Hashable):
|
||||
|
||||
Returns the object's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the object's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
id: :class:`int`
|
||||
|
@ -39,11 +39,8 @@ if TYPE_CHECKING:
|
||||
from .message import Message
|
||||
from .partial_emoji import PartialEmoji
|
||||
from .member import Member
|
||||
from .threads import Thread
|
||||
|
||||
|
||||
from .enums import ChannelType, try_enum
|
||||
|
||||
__all__ = (
|
||||
'RawMessageDeleteEvent',
|
||||
'RawBulkMessageDeleteEvent',
|
||||
@ -52,7 +49,6 @@ __all__ = (
|
||||
'RawReactionClearEvent',
|
||||
'RawReactionClearEmojiEvent',
|
||||
'RawIntegrationDeleteEvent',
|
||||
'RawThreadDeleteEvent',
|
||||
)
|
||||
|
||||
|
||||
@ -280,31 +276,3 @@ class RawIntegrationDeleteEvent(_RawReprMixin):
|
||||
self.application_id: Optional[int] = int(data['application_id'])
|
||||
except KeyError:
|
||||
self.application_id: Optional[int] = None
|
||||
|
||||
class RawThreadDeleteEvent(_RawReprMixin):
|
||||
"""Represents the payload for a :func:`on_raw_thread_delete` event.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Attributes
|
||||
----------
|
||||
thread_id: :class:`int`
|
||||
The ID of the thread that was deleted.
|
||||
thread_type: :class:`discord.ChannelType`
|
||||
The channel type of the deleted thread.
|
||||
guild_id: :class:`int`
|
||||
The ID of the guild the thread was deleted in.
|
||||
parent_id: :class:`int`
|
||||
The ID of the channel the thread was belonged to.
|
||||
thread: Optional[:class:`discord.Thread`]
|
||||
The thread, if it could be found in the internal cache.
|
||||
"""
|
||||
|
||||
__slots__ = ('thread_id', 'thread_type', 'parent_id', 'guild_id', 'thread')
|
||||
|
||||
def __init__(self, data) -> None:
|
||||
self.thread_id: int = int(data['id'])
|
||||
self.thread_type: ChannelType = try_enum(ChannelType, data['type'])
|
||||
self.guild_id: int = int(data['guild_id'])
|
||||
self.parent_id: int = int(data['parent_id'])
|
||||
self.thread: Optional[Thread] = None
|
||||
|
@ -141,14 +141,6 @@ class Role(Hashable):
|
||||
|
||||
Returns the role's name.
|
||||
|
||||
.. describe:: str(x)
|
||||
|
||||
Returns the role's ID.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the role's ID.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
id: :class:`int`
|
||||
@ -203,9 +195,6 @@ class Role(Hashable):
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
def __int__(self) -> int:
|
||||
return self.id
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<Role id={self.id} name={self.name!r}>'
|
||||
|
||||
|
@ -61,10 +61,6 @@ class StageInstance(Hashable):
|
||||
|
||||
Returns the stage instance's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the stage instance's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
id: :class:`int`
|
||||
|
@ -152,7 +152,6 @@ class ConnectionState:
|
||||
handlers: Dict[str, Callable],
|
||||
hooks: Dict[str, Callable],
|
||||
http: HTTPClient,
|
||||
intents: Intents,
|
||||
loop: asyncio.AbstractEventLoop,
|
||||
**options: Any,
|
||||
) -> None:
|
||||
@ -195,8 +194,12 @@ class ConnectionState:
|
||||
else:
|
||||
status = str(status)
|
||||
|
||||
if not isinstance(intents, Intents):
|
||||
raise TypeError(f'intents parameter must be Intent not {type(intents)!r}')
|
||||
intents = options.get('intents', None)
|
||||
if intents is not None:
|
||||
if not isinstance(intents, Intents):
|
||||
raise TypeError(f'intents parameter must be Intent not {type(intents)!r}')
|
||||
else:
|
||||
intents = Intents.default()
|
||||
|
||||
if not intents.guilds:
|
||||
_log.warning('Guilds intent seems to be disabled. This may cause state related issues.')
|
||||
@ -851,10 +854,8 @@ class ConnectionState:
|
||||
_log.debug('THREAD_DELETE referencing an unknown guild ID: %s. Discarding', guild_id)
|
||||
return
|
||||
|
||||
raw = RawThreadDeleteEvent(data)
|
||||
raw.thread = thread = guild.get_thread(raw.thread_id)
|
||||
self.dispatch('raw_thread_delete', raw)
|
||||
|
||||
thread_id = int(data['id'])
|
||||
thread = guild.get_thread(thread_id)
|
||||
if thread is not None:
|
||||
guild._remove_thread(thread) # type: ignore
|
||||
self.dispatch('thread_delete', thread)
|
||||
|
@ -67,14 +67,6 @@ class StickerPack(Hashable):
|
||||
|
||||
Returns the name of the sticker pack.
|
||||
|
||||
.. describe:: hash(x)
|
||||
|
||||
Returns the hash of the sticker pack.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the ID of the sticker pack.
|
||||
|
||||
.. describe:: x == y
|
||||
|
||||
Checks if the sticker pack is equal to another sticker pack.
|
||||
|
@ -74,10 +74,6 @@ class Thread(Messageable, Hashable):
|
||||
|
||||
Returns the thread's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the thread's ID.
|
||||
|
||||
.. describe:: str(x)
|
||||
|
||||
Returns the thread's name.
|
||||
@ -752,10 +748,6 @@ class ThreadMember(Hashable):
|
||||
|
||||
Returns the thread member's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the thread member's ID.
|
||||
|
||||
.. describe:: str(x)
|
||||
|
||||
Returns the thread member's name.
|
||||
|
@ -155,3 +155,10 @@ class StageInstance(TypedDict):
|
||||
topic: str
|
||||
privacy_level: PrivacyLevel
|
||||
discoverable_disabled: bool
|
||||
|
||||
class Party(TypedDict):
|
||||
uses: int
|
||||
max_uses: int
|
||||
max_age: int
|
||||
temporary: bool
|
||||
created_at: str
|
||||
|
@ -96,9 +96,6 @@ class BaseUser(_UserTag):
|
||||
def __str__(self) -> str:
|
||||
return f'{self.name}#{self.discriminator}'
|
||||
|
||||
def __int__(self) -> int:
|
||||
return self.id
|
||||
|
||||
def __eq__(self, other: Any) -> bool:
|
||||
return isinstance(other, _UserTag) and other.id == self.id
|
||||
|
||||
@ -418,10 +415,6 @@ class User(BaseUser, discord.abc.Messageable):
|
||||
|
||||
Returns the user's name with discriminator.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the user's ID.
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
name: :class:`str`
|
||||
|
@ -886,10 +886,6 @@ class Webhook(BaseWebhook):
|
||||
|
||||
Returns the webhooks's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the webhooks's ID.
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
Webhooks are now comparable and hashable.
|
||||
|
||||
|
@ -475,10 +475,6 @@ class SyncWebhook(BaseWebhook):
|
||||
|
||||
Returns the webhooks's hash.
|
||||
|
||||
.. describe:: int(x)
|
||||
|
||||
Returns the webhooks's ID.
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
Webhooks are now comparable and hashable.
|
||||
|
||||
|
26
docs/api.rst
26
docs/api.rst
@ -718,11 +718,7 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
||||
|
||||
.. function:: on_thread_delete(thread)
|
||||
|
||||
Called whenever a thread is deleted. If the thread could
|
||||
not be found in the internal cache this event will not be called.
|
||||
Threads will not be in the cache if they are archived.
|
||||
|
||||
If you need this information use :func:`on_raw_thread_delete` instead.
|
||||
Called whenever a thread is deleted.
|
||||
|
||||
Note that you can get the guild from :attr:`Thread.guild`.
|
||||
|
||||
@ -733,18 +729,6 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
||||
:param thread: The thread that got deleted.
|
||||
:type thread: :class:`Thread`
|
||||
|
||||
.. function:: on_raw_thread_delete(payload)
|
||||
|
||||
Called whenever a thread is deleted. Unlike :func:`on_thread_delete` this
|
||||
is called regardless of the thread being in the internal thread cache or not.
|
||||
|
||||
This requires :attr:`Intents.guilds` to be enabled.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
:param payload: The raw event payload data.
|
||||
:type payload: :class:`RawThreadDeleteEvent`
|
||||
|
||||
.. function:: on_thread_member_join(member)
|
||||
on_thread_member_remove(member)
|
||||
|
||||
@ -3918,14 +3902,6 @@ RawIntegrationDeleteEvent
|
||||
.. autoclass:: RawIntegrationDeleteEvent()
|
||||
:members:
|
||||
|
||||
RawThreadDeleteEvent
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. attributetable:: RawThreadDeleteEvent
|
||||
|
||||
.. autoclass:: RawThreadDeleteEvent()
|
||||
:members:
|
||||
|
||||
PartialWebhookGuild
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -26,5 +26,5 @@ class MyClient(discord.Client):
|
||||
async def before_my_task(self):
|
||||
await self.wait_until_ready() # wait until the bot logs in
|
||||
|
||||
client = MyClient(intents=discord.Intents(guilds=True))
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
@ -22,5 +22,5 @@ class MyClient(discord.Client):
|
||||
await asyncio.sleep(60) # task runs every 60 seconds
|
||||
|
||||
|
||||
client = MyClient(intents=discord.Intents(guilds=True))
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
@ -9,8 +9,10 @@ module.
|
||||
|
||||
There are a number of utility commands being showcased here.'''
|
||||
|
||||
intents = discord.Intents(guilds=True, messages=True, members=True)
|
||||
bot = commands.Bot(command_prefix='t-', description=description, intents=intents)
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
|
||||
bot = commands.Bot(command_prefix='?', description=description, intents=intents)
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
|
@ -123,11 +123,8 @@ class Music(commands.Cog):
|
||||
elif ctx.voice_client.is_playing():
|
||||
ctx.voice_client.stop()
|
||||
|
||||
bot = commands.Bot(
|
||||
command_prefix=commands.when_mentioned_or("!"),
|
||||
description='Relatively simple music bot example',
|
||||
intents=discord.Intents(guilds=True, guild_messages=True, voice_states=True)
|
||||
)
|
||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"),
|
||||
description='Relatively simple music bot example')
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
|
@ -5,8 +5,9 @@ import typing
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
|
||||
intents = discord.Intents(guilds=True, messages=True, members=True)
|
||||
bot = commands.Bot('!', intents=intents)
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ class MyBot(commands.Bot):
|
||||
return await super().get_context(message, cls=cls)
|
||||
|
||||
|
||||
bot = MyBot(command_prefix='!', intents=discord.Intents(guilds=True, messages=True))
|
||||
bot = MyBot(command_prefix='!')
|
||||
|
||||
@bot.command()
|
||||
async def guess(ctx, number: int):
|
||||
|
@ -17,5 +17,5 @@ class MyClient(discord.Client):
|
||||
msg = f'{message.author} has deleted the message: {message.content}'
|
||||
await message.channel.send(msg)
|
||||
|
||||
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
@ -16,5 +16,5 @@ class MyClient(discord.Client):
|
||||
msg = f'**{before.author}** edited their message:\n{before.content} -> {after.content}'
|
||||
await before.channel.send(msg)
|
||||
|
||||
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
@ -30,5 +30,5 @@ class MyClient(discord.Client):
|
||||
else:
|
||||
await message.channel.send(f'Oops. It is actually {answer}.')
|
||||
|
||||
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
@ -14,5 +14,8 @@ class MyClient(discord.Client):
|
||||
await guild.system_channel.send(to_send)
|
||||
|
||||
|
||||
client = MyClient(intents=discord.Intents(guilds=True, members=True))
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
|
||||
client = MyClient(intents=intents)
|
||||
client.run('token')
|
||||
|
@ -78,6 +78,8 @@ class MyClient(discord.Client):
|
||||
# If we want to do something in case of errors we'd do it here.
|
||||
pass
|
||||
|
||||
intents = discord.Intents(guilds=True, members=True, guild_reactions=True)
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
|
||||
client = MyClient(intents=intents)
|
||||
client.run('token')
|
||||
|
@ -13,5 +13,5 @@ class MyClient(discord.Client):
|
||||
if message.content.startswith('!hello'):
|
||||
await message.reply('Hello!', mention_author=True)
|
||||
|
||||
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
@ -3,11 +3,7 @@ import typing
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
bot = commands.Bot(
|
||||
command_prefix=commands.when_mentioned,
|
||||
description="Nothing to see here!",
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
bot = commands.Bot(command_prefix=commands.when_mentioned, description="Nothing to see here!")
|
||||
|
||||
# the `hidden` keyword argument hides it from the help command.
|
||||
@bot.group(hidden=True)
|
||||
|
@ -5,10 +5,7 @@ import discord
|
||||
|
||||
class Bot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
|
@ -5,10 +5,7 @@ import discord
|
||||
|
||||
class CounterBot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
|
@ -1,3 +1,5 @@
|
||||
import typing
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
@ -37,10 +39,7 @@ class DropdownView(discord.ui.View):
|
||||
|
||||
class Bot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
|
@ -4,10 +4,7 @@ import discord
|
||||
|
||||
class EphemeralCounterBot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
|
@ -5,10 +5,7 @@ from urllib.parse import quote_plus
|
||||
|
||||
class GoogleBot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
@ -39,4 +36,4 @@ async def google(ctx: commands.Context, *, query: str):
|
||||
await ctx.send(f'Google Result for: `{query}`', view=Google(query))
|
||||
|
||||
|
||||
bot.run()
|
||||
bot.run('token')
|
||||
|
@ -29,11 +29,7 @@ class PersistentView(discord.ui.View):
|
||||
|
||||
class PersistentViewBot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
|
||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
||||
self.persistent_views_added = False
|
||||
|
||||
async def on_ready(self):
|
||||
|
@ -120,10 +120,7 @@ class TicTacToe(discord.ui.View):
|
||||
|
||||
class TicTacToeBot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
|
Reference in New Issue
Block a user