Compare commits
21 Commits
wasi-maste
...
paris-ci/p
Author | SHA1 | Date | |
---|---|---|---|
|
5a51f9dd23 | ||
|
c34612dd71 | ||
|
6f5614373a | ||
|
2e12746c70 | ||
|
5ef72e4f70 | ||
|
7e18d30820 | ||
|
923a6a885d | ||
|
b28893aa36 | ||
|
6e41bd2219 | ||
|
64ee792391 | ||
|
22de755059 | ||
|
fa7f8efc8e | ||
|
9d1df65af3 | ||
|
3ce86f6cde | ||
|
31e3e99c2b | ||
|
cc90d312f5 | ||
|
75f052b8c9 | ||
|
c8cdb275c5 | ||
|
406f0ffe04 | ||
|
a4acbd2e08 | ||
|
e4750c7105 |
@@ -313,7 +313,8 @@ class Asset(AssetMixin):
|
|||||||
if self._animated:
|
if self._animated:
|
||||||
if format not in VALID_ASSET_FORMATS:
|
if format not in VALID_ASSET_FORMATS:
|
||||||
raise InvalidArgument(f'format must be one of {VALID_ASSET_FORMATS}')
|
raise InvalidArgument(f'format must be one of {VALID_ASSET_FORMATS}')
|
||||||
else:
|
url = url.with_path(f'{path}.{format}')
|
||||||
|
elif static_format is MISSING:
|
||||||
if format not in VALID_STATIC_FORMATS:
|
if format not in VALID_STATIC_FORMATS:
|
||||||
raise InvalidArgument(f'format must be one of {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}')
|
||||||
|
@@ -330,6 +330,10 @@ class AuditLogEntry(Hashable):
|
|||||||
|
|
||||||
Returns the entry's hash.
|
Returns the entry's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the entry's ID.
|
||||||
|
|
||||||
.. versionchanged:: 1.7
|
.. versionchanged:: 1.7
|
||||||
Audit log entries are now comparable and hashable.
|
Audit log entries are now comparable and hashable.
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ import datetime
|
|||||||
|
|
||||||
import discord.abc
|
import discord.abc
|
||||||
from .permissions import PermissionOverwrite, Permissions
|
from .permissions import PermissionOverwrite, Permissions
|
||||||
from .enums import ChannelType, StagePrivacyLevel, try_enum, VoiceRegion, VideoQualityMode, PartyType
|
from .enums import ChannelType, StagePrivacyLevel, try_enum, VoiceRegion, VideoQualityMode
|
||||||
from .mixins import Hashable
|
from .mixins import Hashable
|
||||||
from .object import Object
|
from .object import Object
|
||||||
from . import utils
|
from . import utils
|
||||||
@@ -115,6 +115,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
|
|
||||||
Returns the channel's name.
|
Returns the channel's name.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the channel's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
@@ -1037,38 +1041,6 @@ class VoiceChannel(VocalGuildChannel):
|
|||||||
# the payload will always be the proper channel payload
|
# the payload will always be the proper channel payload
|
||||||
return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore
|
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):
|
class StageChannel(VocalGuildChannel):
|
||||||
"""Represents a Discord guild stage channel.
|
"""Represents a Discord guild stage channel.
|
||||||
@@ -1366,6 +1338,10 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
|
|||||||
|
|
||||||
Returns the category's name.
|
Returns the category's name.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the category's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
@@ -1588,6 +1564,10 @@ class StoreChannel(discord.abc.GuildChannel, Hashable):
|
|||||||
|
|
||||||
Returns the channel's name.
|
Returns the channel's name.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the channel's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
@@ -1760,6 +1740,10 @@ class DMChannel(discord.abc.Messageable, Hashable):
|
|||||||
|
|
||||||
Returns a string representation of the channel
|
Returns a string representation of the channel
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the channel's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
recipient: Optional[:class:`User`]
|
recipient: Optional[:class:`User`]
|
||||||
@@ -1886,6 +1870,10 @@ class GroupChannel(discord.abc.Messageable, Hashable):
|
|||||||
|
|
||||||
Returns a string representation of the channel
|
Returns a string representation of the channel
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the channel's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
recipients: List[:class:`User`]
|
recipients: List[:class:`User`]
|
||||||
@@ -2032,6 +2020,10 @@ class PartialMessageable(discord.abc.Messageable, Hashable):
|
|||||||
|
|
||||||
Returns the partial messageable's hash.
|
Returns the partial messageable's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the messageable's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
id: :class:`int`
|
id: :class:`int`
|
||||||
@@ -2070,76 +2062,6 @@ class PartialMessageable(discord.abc.Messageable, Hashable):
|
|||||||
|
|
||||||
return PartialMessage(channel=self, id=message_id)
|
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):
|
def _guild_channel_factory(channel_type: int):
|
||||||
value = try_enum(ChannelType, channel_type)
|
value = try_enum(ChannelType, channel_type)
|
||||||
|
@@ -142,7 +142,6 @@ class Client:
|
|||||||
intents: :class:`Intents`
|
intents: :class:`Intents`
|
||||||
The intents that you want to enable for the session. This is a way of
|
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.
|
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
|
.. versionadded:: 1.5
|
||||||
member_cache_flags: :class:`MemberCacheFlags`
|
member_cache_flags: :class:`MemberCacheFlags`
|
||||||
@@ -203,9 +202,12 @@ class Client:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
intents: Intents,
|
||||||
loop: Optional[asyncio.AbstractEventLoop] = None,
|
loop: Optional[asyncio.AbstractEventLoop] = None,
|
||||||
**options: Any,
|
**options: Any,
|
||||||
):
|
):
|
||||||
|
options["intents"] = intents
|
||||||
|
|
||||||
# self.ws is set in the connect method
|
# self.ws is set in the connect method
|
||||||
self.ws: DiscordWebSocket = None # type: ignore
|
self.ws: DiscordWebSocket = None # type: ignore
|
||||||
self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop() if loop is None else loop
|
self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop() if loop is None else loop
|
||||||
|
@@ -325,5 +325,14 @@ class Colour:
|
|||||||
"""
|
"""
|
||||||
return cls(0xFEE75C)
|
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
|
Color = Colour
|
||||||
|
@@ -72,30 +72,36 @@ if TYPE_CHECKING:
|
|||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
MaybeEmpty = Union[T, _EmptyEmbed]
|
MaybeEmpty = Union[T, _EmptyEmbed]
|
||||||
|
|
||||||
|
|
||||||
class _EmbedFooterProxy(Protocol):
|
class _EmbedFooterProxy(Protocol):
|
||||||
text: MaybeEmpty[str]
|
text: MaybeEmpty[str]
|
||||||
icon_url: MaybeEmpty[str]
|
icon_url: MaybeEmpty[str]
|
||||||
|
|
||||||
|
|
||||||
class _EmbedFieldProxy(Protocol):
|
class _EmbedFieldProxy(Protocol):
|
||||||
name: MaybeEmpty[str]
|
name: MaybeEmpty[str]
|
||||||
value: MaybeEmpty[str]
|
value: MaybeEmpty[str]
|
||||||
inline: bool
|
inline: bool
|
||||||
|
|
||||||
|
|
||||||
class _EmbedMediaProxy(Protocol):
|
class _EmbedMediaProxy(Protocol):
|
||||||
url: MaybeEmpty[str]
|
url: MaybeEmpty[str]
|
||||||
proxy_url: MaybeEmpty[str]
|
proxy_url: MaybeEmpty[str]
|
||||||
height: MaybeEmpty[int]
|
height: MaybeEmpty[int]
|
||||||
width: MaybeEmpty[int]
|
width: MaybeEmpty[int]
|
||||||
|
|
||||||
|
|
||||||
class _EmbedVideoProxy(Protocol):
|
class _EmbedVideoProxy(Protocol):
|
||||||
url: MaybeEmpty[str]
|
url: MaybeEmpty[str]
|
||||||
height: MaybeEmpty[int]
|
height: MaybeEmpty[int]
|
||||||
width: MaybeEmpty[int]
|
width: MaybeEmpty[int]
|
||||||
|
|
||||||
|
|
||||||
class _EmbedProviderProxy(Protocol):
|
class _EmbedProviderProxy(Protocol):
|
||||||
name: MaybeEmpty[str]
|
name: MaybeEmpty[str]
|
||||||
url: MaybeEmpty[str]
|
url: MaybeEmpty[str]
|
||||||
|
|
||||||
|
|
||||||
class _EmbedAuthorProxy(Protocol):
|
class _EmbedAuthorProxy(Protocol):
|
||||||
name: MaybeEmpty[str]
|
name: MaybeEmpty[str]
|
||||||
url: MaybeEmpty[str]
|
url: MaybeEmpty[str]
|
||||||
@@ -397,6 +403,19 @@ class Embed:
|
|||||||
"""
|
"""
|
||||||
return EmbedProxy(getattr(self, '_image', {})) # type: ignore
|
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:
|
def set_image(self: E, *, url: MaybeEmpty[Any]) -> E:
|
||||||
"""Sets the image for the embed content.
|
"""Sets the image for the embed content.
|
||||||
|
|
||||||
@@ -413,14 +432,9 @@ class Embed:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if url is EmptyEmbed:
|
if url is EmptyEmbed:
|
||||||
try:
|
del self.image
|
||||||
del self._image
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
self._image = {
|
self.image = url
|
||||||
'url': str(url),
|
|
||||||
}
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@@ -439,7 +453,25 @@ class Embed:
|
|||||||
"""
|
"""
|
||||||
return EmbedProxy(getattr(self, '_thumbnail', {})) # type: ignore
|
return EmbedProxy(getattr(self, '_thumbnail', {})) # type: ignore
|
||||||
|
|
||||||
def set_thumbnail(self: E, *, url: MaybeEmpty[Any]) -> E:
|
@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]):
|
||||||
"""Sets the thumbnail for the embed content.
|
"""Sets the thumbnail for the embed content.
|
||||||
|
|
||||||
This function returns the class instance to allow for fluent-style
|
This function returns the class instance to allow for fluent-style
|
||||||
@@ -453,16 +485,10 @@ class Embed:
|
|||||||
url: :class:`str`
|
url: :class:`str`
|
||||||
The source URL for the thumbnail. Only HTTP(S) is supported.
|
The source URL for the thumbnail. Only HTTP(S) is supported.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if url is EmptyEmbed:
|
if url is EmptyEmbed:
|
||||||
try:
|
del self.thumbnail
|
||||||
del self._thumbnail
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
self._thumbnail = {
|
self.thumbnail = url
|
||||||
'url': str(url),
|
|
||||||
}
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@@ -72,6 +72,10 @@ class Emoji(_EmojiTag, AssetMixin):
|
|||||||
|
|
||||||
Returns the emoji rendered for discord.
|
Returns the emoji rendered for discord.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the emoji ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
@@ -137,6 +141,9 @@ class Emoji(_EmojiTag, AssetMixin):
|
|||||||
return f'<a:{self.name}:{self.id}>'
|
return f'<a:{self.name}:{self.id}>'
|
||||||
return f'<:{self.name}:{self.id}>'
|
return f'<:{self.name}:{self.id}>'
|
||||||
|
|
||||||
|
def __int__(self) -> int:
|
||||||
|
return self.id
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<Emoji id={self.id} name={self.name!r} animated={self.animated} managed={self.managed}>'
|
return f'<Emoji id={self.id} name={self.name!r} animated={self.animated} managed={self.managed}>'
|
||||||
|
|
||||||
|
@@ -30,7 +30,6 @@ __all__ = (
|
|||||||
'Enum',
|
'Enum',
|
||||||
'ChannelType',
|
'ChannelType',
|
||||||
'MessageType',
|
'MessageType',
|
||||||
'PartyType',
|
|
||||||
'VoiceRegion',
|
'VoiceRegion',
|
||||||
'SpeakingState',
|
'SpeakingState',
|
||||||
'VerificationLevel',
|
'VerificationLevel',
|
||||||
@@ -215,14 +214,6 @@ class MessageType(Enum):
|
|||||||
guild_invite_reminder = 22
|
guild_invite_reminder = 22
|
||||||
|
|
||||||
|
|
||||||
class PartyType(Enum):
|
|
||||||
youtube = 755600276941176913
|
|
||||||
poker = 755827207812677713
|
|
||||||
betrayal = 773336526917861400
|
|
||||||
fishing = 814288819477020702
|
|
||||||
chess = 832012774040141894
|
|
||||||
|
|
||||||
|
|
||||||
class VoiceRegion(Enum):
|
class VoiceRegion(Enum):
|
||||||
us_west = 'us-west'
|
us_west = 'us-west'
|
||||||
us_east = 'us-east'
|
us_east = 'us-east'
|
||||||
|
@@ -120,8 +120,8 @@ class _DefaultRepr:
|
|||||||
_default = _DefaultRepr()
|
_default = _DefaultRepr()
|
||||||
|
|
||||||
class BotBase(GroupMixin):
|
class BotBase(GroupMixin):
|
||||||
def __init__(self, command_prefix, help_command=_default, description=None, **options):
|
def __init__(self, command_prefix, help_command=_default, description=None, *, intents: discord.Intents, **options):
|
||||||
super().__init__(**options)
|
super().__init__(**options, intents=intents)
|
||||||
self.command_prefix = command_prefix
|
self.command_prefix = command_prefix
|
||||||
self.extra_events: Dict[str, List[CoroFunc]] = {}
|
self.extra_events: Dict[str, List[CoroFunc]] = {}
|
||||||
self.__cogs: Dict[str, Cog] = {}
|
self.__cogs: Dict[str, Cog] = {}
|
||||||
|
@@ -480,16 +480,6 @@ class Intents(BaseFlags):
|
|||||||
self.value = self.DEFAULT_VALUE
|
self.value = self.DEFAULT_VALUE
|
||||||
return self
|
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
|
@flag_value
|
||||||
def guilds(self):
|
def guilds(self):
|
||||||
""":class:`bool`: Whether guild related events are enabled.
|
""":class:`bool`: Whether guild related events are enabled.
|
||||||
|
@@ -140,6 +140,10 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
Returns the guild's name.
|
Returns the guild's name.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the guild's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
@@ -738,12 +742,16 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def humans(self) -> List[Member]:
|
def humans(self) -> List[Member]:
|
||||||
"""List[:class:`Member`]: A list of human members that belong to this guild."""
|
"""List[:class:`Member`]: A list of human members that belong to this guild.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0 """
|
||||||
return [member for member in self.members if not member.bot]
|
return [member for member in self.members if not member.bot]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bots(self) -> List[Member]:
|
def bots(self) -> List[Member]:
|
||||||
"""List[:class:`Member`]: A list of bots that belong to this guild."""
|
"""List[:class:`Member`]: A list of bots that belong to this guild.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0 """
|
||||||
return [member for member in self.members if member.bot]
|
return [member for member in self.members if member.bot]
|
||||||
|
|
||||||
def get_member(self, user_id: int, /) -> Optional[Member]:
|
def get_member(self, user_id: int, /) -> Optional[Member]:
|
||||||
|
@@ -880,24 +880,6 @@ class HTTPClient:
|
|||||||
) -> Response[None]:
|
) -> Response[None]:
|
||||||
return self.request(Route('DELETE', '/channels/{channel_id}', channel_id=channel_id), reason=reason)
|
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
|
# Thread management
|
||||||
|
|
||||||
def start_thread_with_message(
|
def start_thread_with_message(
|
||||||
|
@@ -230,6 +230,7 @@ class Invite(Hashable):
|
|||||||
|
|
||||||
Returns the invite URL.
|
Returns the invite URL.
|
||||||
|
|
||||||
|
|
||||||
The following table illustrates what methods will obtain the attributes:
|
The following table illustrates what methods will obtain the attributes:
|
||||||
|
|
||||||
+------------------------------------+------------------------------------------------------------+
|
+------------------------------------+------------------------------------------------------------+
|
||||||
@@ -433,6 +434,9 @@ class Invite(Hashable):
|
|||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.url
|
return self.url
|
||||||
|
|
||||||
|
def __int__(self) -> int:
|
||||||
|
return 0 # To keep the object compatible with the hashable abc.
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return (
|
return (
|
||||||
f'<Invite code={self.code!r} guild={self.guild!r} '
|
f'<Invite code={self.code!r} guild={self.guild!r} '
|
||||||
|
@@ -226,6 +226,10 @@ class Member(discord.abc.Messageable, _UserTag):
|
|||||||
|
|
||||||
Returns the member's name with the discriminator.
|
Returns the member's name with the discriminator.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the user's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
joined_at: Optional[:class:`datetime.datetime`]
|
joined_at: Optional[:class:`datetime.datetime`]
|
||||||
@@ -300,6 +304,9 @@ class Member(discord.abc.Messageable, _UserTag):
|
|||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return str(self._user)
|
return str(self._user)
|
||||||
|
|
||||||
|
def __int__(self) -> int:
|
||||||
|
return self.id
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return (
|
return (
|
||||||
f'<Member id={self._user.id} name={self._user.name!r} discriminator={self._user.discriminator!r}'
|
f'<Member id={self._user.id} name={self._user.name!r} discriminator={self._user.discriminator!r}'
|
||||||
|
@@ -125,6 +125,10 @@ class Attachment(Hashable):
|
|||||||
|
|
||||||
Returns the hash of the attachment.
|
Returns the hash of the attachment.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the attachment's ID.
|
||||||
|
|
||||||
.. versionchanged:: 1.7
|
.. versionchanged:: 1.7
|
||||||
Attachment can now be casted to :class:`str` and is hashable.
|
Attachment can now be casted to :class:`str` and is hashable.
|
||||||
|
|
||||||
@@ -503,6 +507,14 @@ class Message(Hashable):
|
|||||||
|
|
||||||
Returns the message's hash.
|
Returns the message's hash.
|
||||||
|
|
||||||
|
.. describe:: str(x)
|
||||||
|
|
||||||
|
Returns the message's content.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the message's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
tts: :class:`bool`
|
tts: :class:`bool`
|
||||||
@@ -712,6 +724,10 @@ class Message(Hashable):
|
|||||||
f'<{name} id={self.id} channel={self.channel!r} type={self.type!r} author={self.author!r} flags={self.flags!r}>'
|
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:
|
def _try_patch(self, data, key, transform=None) -> None:
|
||||||
try:
|
try:
|
||||||
value = data[key]
|
value = data[key]
|
||||||
@@ -1634,6 +1650,10 @@ class PartialMessage(Hashable):
|
|||||||
|
|
||||||
Returns the partial message's hash.
|
Returns the partial message's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the partial message's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
channel: Union[:class:`TextChannel`, :class:`Thread`, :class:`DMChannel`]
|
channel: Union[:class:`TextChannel`, :class:`Thread`, :class:`DMChannel`]
|
||||||
|
@@ -43,5 +43,8 @@ class EqualityComparable:
|
|||||||
class Hashable(EqualityComparable):
|
class Hashable(EqualityComparable):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
|
def __int__(self) -> int:
|
||||||
|
return self.id
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return self.id >> 22
|
return self.id >> 22
|
||||||
|
@@ -69,6 +69,10 @@ class Object(Hashable):
|
|||||||
|
|
||||||
Returns the object's hash.
|
Returns the object's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the object's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
id: :class:`int`
|
id: :class:`int`
|
||||||
|
@@ -39,8 +39,11 @@ if TYPE_CHECKING:
|
|||||||
from .message import Message
|
from .message import Message
|
||||||
from .partial_emoji import PartialEmoji
|
from .partial_emoji import PartialEmoji
|
||||||
from .member import Member
|
from .member import Member
|
||||||
|
from .threads import Thread
|
||||||
|
|
||||||
|
|
||||||
|
from .enums import ChannelType, try_enum
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'RawMessageDeleteEvent',
|
'RawMessageDeleteEvent',
|
||||||
'RawBulkMessageDeleteEvent',
|
'RawBulkMessageDeleteEvent',
|
||||||
@@ -49,6 +52,7 @@ __all__ = (
|
|||||||
'RawReactionClearEvent',
|
'RawReactionClearEvent',
|
||||||
'RawReactionClearEmojiEvent',
|
'RawReactionClearEmojiEvent',
|
||||||
'RawIntegrationDeleteEvent',
|
'RawIntegrationDeleteEvent',
|
||||||
|
'RawThreadDeleteEvent',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -276,3 +280,31 @@ class RawIntegrationDeleteEvent(_RawReprMixin):
|
|||||||
self.application_id: Optional[int] = int(data['application_id'])
|
self.application_id: Optional[int] = int(data['application_id'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.application_id: Optional[int] = None
|
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,6 +141,14 @@ class Role(Hashable):
|
|||||||
|
|
||||||
Returns the role's name.
|
Returns the role's name.
|
||||||
|
|
||||||
|
.. describe:: str(x)
|
||||||
|
|
||||||
|
Returns the role's ID.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the role's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
id: :class:`int`
|
id: :class:`int`
|
||||||
@@ -195,6 +203,9 @@ class Role(Hashable):
|
|||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def __int__(self) -> int:
|
||||||
|
return self.id
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<Role id={self.id} name={self.name!r}>'
|
return f'<Role id={self.id} name={self.name!r}>'
|
||||||
|
|
||||||
|
@@ -61,6 +61,10 @@ class StageInstance(Hashable):
|
|||||||
|
|
||||||
Returns the stage instance's hash.
|
Returns the stage instance's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the stage instance's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
id: :class:`int`
|
id: :class:`int`
|
||||||
|
@@ -152,6 +152,7 @@ class ConnectionState:
|
|||||||
handlers: Dict[str, Callable],
|
handlers: Dict[str, Callable],
|
||||||
hooks: Dict[str, Callable],
|
hooks: Dict[str, Callable],
|
||||||
http: HTTPClient,
|
http: HTTPClient,
|
||||||
|
intents: Intents,
|
||||||
loop: asyncio.AbstractEventLoop,
|
loop: asyncio.AbstractEventLoop,
|
||||||
**options: Any,
|
**options: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -194,12 +195,8 @@ class ConnectionState:
|
|||||||
else:
|
else:
|
||||||
status = str(status)
|
status = str(status)
|
||||||
|
|
||||||
intents = options.get('intents', None)
|
|
||||||
if intents is not None:
|
|
||||||
if not isinstance(intents, Intents):
|
if not isinstance(intents, Intents):
|
||||||
raise TypeError(f'intents parameter must be Intent not {type(intents)!r}')
|
raise TypeError(f'intents parameter must be Intent not {type(intents)!r}')
|
||||||
else:
|
|
||||||
intents = Intents.default()
|
|
||||||
|
|
||||||
if not intents.guilds:
|
if not intents.guilds:
|
||||||
_log.warning('Guilds intent seems to be disabled. This may cause state related issues.')
|
_log.warning('Guilds intent seems to be disabled. This may cause state related issues.')
|
||||||
@@ -854,8 +851,10 @@ class ConnectionState:
|
|||||||
_log.debug('THREAD_DELETE referencing an unknown guild ID: %s. Discarding', guild_id)
|
_log.debug('THREAD_DELETE referencing an unknown guild ID: %s. Discarding', guild_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
thread_id = int(data['id'])
|
raw = RawThreadDeleteEvent(data)
|
||||||
thread = guild.get_thread(thread_id)
|
raw.thread = thread = guild.get_thread(raw.thread_id)
|
||||||
|
self.dispatch('raw_thread_delete', raw)
|
||||||
|
|
||||||
if thread is not None:
|
if thread is not None:
|
||||||
guild._remove_thread(thread) # type: ignore
|
guild._remove_thread(thread) # type: ignore
|
||||||
self.dispatch('thread_delete', thread)
|
self.dispatch('thread_delete', thread)
|
||||||
|
@@ -67,6 +67,14 @@ class StickerPack(Hashable):
|
|||||||
|
|
||||||
Returns the name of the sticker pack.
|
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
|
.. describe:: x == y
|
||||||
|
|
||||||
Checks if the sticker pack is equal to another sticker pack.
|
Checks if the sticker pack is equal to another sticker pack.
|
||||||
|
@@ -74,6 +74,10 @@ class Thread(Messageable, Hashable):
|
|||||||
|
|
||||||
Returns the thread's hash.
|
Returns the thread's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the thread's ID.
|
||||||
|
|
||||||
.. describe:: str(x)
|
.. describe:: str(x)
|
||||||
|
|
||||||
Returns the thread's name.
|
Returns the thread's name.
|
||||||
@@ -748,6 +752,10 @@ class ThreadMember(Hashable):
|
|||||||
|
|
||||||
Returns the thread member's hash.
|
Returns the thread member's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the thread member's ID.
|
||||||
|
|
||||||
.. describe:: str(x)
|
.. describe:: str(x)
|
||||||
|
|
||||||
Returns the thread member's name.
|
Returns the thread member's name.
|
||||||
|
@@ -155,10 +155,3 @@ class StageInstance(TypedDict):
|
|||||||
topic: str
|
topic: str
|
||||||
privacy_level: PrivacyLevel
|
privacy_level: PrivacyLevel
|
||||||
discoverable_disabled: bool
|
discoverable_disabled: bool
|
||||||
|
|
||||||
class Party(TypedDict):
|
|
||||||
uses: int
|
|
||||||
max_uses: int
|
|
||||||
max_age: int
|
|
||||||
temporary: bool
|
|
||||||
created_at: str
|
|
||||||
|
@@ -96,6 +96,9 @@ class BaseUser(_UserTag):
|
|||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f'{self.name}#{self.discriminator}'
|
return f'{self.name}#{self.discriminator}'
|
||||||
|
|
||||||
|
def __int__(self) -> int:
|
||||||
|
return self.id
|
||||||
|
|
||||||
def __eq__(self, other: Any) -> bool:
|
def __eq__(self, other: Any) -> bool:
|
||||||
return isinstance(other, _UserTag) and other.id == self.id
|
return isinstance(other, _UserTag) and other.id == self.id
|
||||||
|
|
||||||
@@ -415,6 +418,10 @@ class User(BaseUser, discord.abc.Messageable):
|
|||||||
|
|
||||||
Returns the user's name with discriminator.
|
Returns the user's name with discriminator.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the user's ID.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
|
@@ -886,6 +886,10 @@ class Webhook(BaseWebhook):
|
|||||||
|
|
||||||
Returns the webhooks's hash.
|
Returns the webhooks's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the webhooks's ID.
|
||||||
|
|
||||||
.. versionchanged:: 1.4
|
.. versionchanged:: 1.4
|
||||||
Webhooks are now comparable and hashable.
|
Webhooks are now comparable and hashable.
|
||||||
|
|
||||||
|
@@ -475,6 +475,10 @@ class SyncWebhook(BaseWebhook):
|
|||||||
|
|
||||||
Returns the webhooks's hash.
|
Returns the webhooks's hash.
|
||||||
|
|
||||||
|
.. describe:: int(x)
|
||||||
|
|
||||||
|
Returns the webhooks's ID.
|
||||||
|
|
||||||
.. versionchanged:: 1.4
|
.. versionchanged:: 1.4
|
||||||
Webhooks are now comparable and hashable.
|
Webhooks are now comparable and hashable.
|
||||||
|
|
||||||
|
26
docs/api.rst
26
docs/api.rst
@@ -718,7 +718,11 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
|||||||
|
|
||||||
.. function:: on_thread_delete(thread)
|
.. function:: on_thread_delete(thread)
|
||||||
|
|
||||||
Called whenever a thread is deleted.
|
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.
|
||||||
|
|
||||||
Note that you can get the guild from :attr:`Thread.guild`.
|
Note that you can get the guild from :attr:`Thread.guild`.
|
||||||
|
|
||||||
@@ -729,6 +733,18 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
|||||||
:param thread: The thread that got deleted.
|
:param thread: The thread that got deleted.
|
||||||
:type thread: :class:`Thread`
|
: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)
|
.. function:: on_thread_member_join(member)
|
||||||
on_thread_member_remove(member)
|
on_thread_member_remove(member)
|
||||||
|
|
||||||
@@ -3902,6 +3918,14 @@ RawIntegrationDeleteEvent
|
|||||||
.. autoclass:: RawIntegrationDeleteEvent()
|
.. autoclass:: RawIntegrationDeleteEvent()
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
RawThreadDeleteEvent
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. attributetable:: RawThreadDeleteEvent
|
||||||
|
|
||||||
|
.. autoclass:: RawThreadDeleteEvent()
|
||||||
|
:members:
|
||||||
|
|
||||||
PartialWebhookGuild
|
PartialWebhookGuild
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@@ -26,5 +26,5 @@ class MyClient(discord.Client):
|
|||||||
async def before_my_task(self):
|
async def before_my_task(self):
|
||||||
await self.wait_until_ready() # wait until the bot logs in
|
await self.wait_until_ready() # wait until the bot logs in
|
||||||
|
|
||||||
client = MyClient()
|
client = MyClient(intents=discord.Intents(guilds=True))
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -22,5 +22,5 @@ class MyClient(discord.Client):
|
|||||||
await asyncio.sleep(60) # task runs every 60 seconds
|
await asyncio.sleep(60) # task runs every 60 seconds
|
||||||
|
|
||||||
|
|
||||||
client = MyClient()
|
client = MyClient(intents=discord.Intents(guilds=True))
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -9,10 +9,8 @@ module.
|
|||||||
|
|
||||||
There are a number of utility commands being showcased here.'''
|
There are a number of utility commands being showcased here.'''
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents(guilds=True, messages=True, members=True)
|
||||||
intents.members = True
|
bot = commands.Bot(command_prefix='t-', description=description, intents=intents)
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix='?', description=description, intents=intents)
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
@@ -123,8 +123,11 @@ class Music(commands.Cog):
|
|||||||
elif ctx.voice_client.is_playing():
|
elif ctx.voice_client.is_playing():
|
||||||
ctx.voice_client.stop()
|
ctx.voice_client.stop()
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"),
|
bot = commands.Bot(
|
||||||
description='Relatively simple music bot example')
|
command_prefix=commands.when_mentioned_or("!"),
|
||||||
|
description='Relatively simple music bot example',
|
||||||
|
intents=discord.Intents(guilds=True, guild_messages=True, voice_states=True)
|
||||||
|
)
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
@@ -5,9 +5,8 @@ import typing
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
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)
|
bot = commands.Bot('!', intents=intents)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ class MyBot(commands.Bot):
|
|||||||
return await super().get_context(message, cls=cls)
|
return await super().get_context(message, cls=cls)
|
||||||
|
|
||||||
|
|
||||||
bot = MyBot(command_prefix='!')
|
bot = MyBot(command_prefix='!', intents=discord.Intents(guilds=True, messages=True))
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def guess(ctx, number: int):
|
async def guess(ctx, number: int):
|
||||||
|
@@ -17,5 +17,5 @@ class MyClient(discord.Client):
|
|||||||
msg = f'{message.author} has deleted the message: {message.content}'
|
msg = f'{message.author} has deleted the message: {message.content}'
|
||||||
await message.channel.send(msg)
|
await message.channel.send(msg)
|
||||||
|
|
||||||
client = MyClient()
|
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -16,5 +16,5 @@ class MyClient(discord.Client):
|
|||||||
msg = f'**{before.author}** edited their message:\n{before.content} -> {after.content}'
|
msg = f'**{before.author}** edited their message:\n{before.content} -> {after.content}'
|
||||||
await before.channel.send(msg)
|
await before.channel.send(msg)
|
||||||
|
|
||||||
client = MyClient()
|
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -30,5 +30,5 @@ class MyClient(discord.Client):
|
|||||||
else:
|
else:
|
||||||
await message.channel.send(f'Oops. It is actually {answer}.')
|
await message.channel.send(f'Oops. It is actually {answer}.')
|
||||||
|
|
||||||
client = MyClient()
|
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -14,8 +14,5 @@ class MyClient(discord.Client):
|
|||||||
await guild.system_channel.send(to_send)
|
await guild.system_channel.send(to_send)
|
||||||
|
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
client = MyClient(intents=discord.Intents(guilds=True, members=True))
|
||||||
intents.members = True
|
|
||||||
|
|
||||||
client = MyClient(intents=intents)
|
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -78,8 +78,6 @@ class MyClient(discord.Client):
|
|||||||
# If we want to do something in case of errors we'd do it here.
|
# If we want to do something in case of errors we'd do it here.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents(guilds=True, members=True, guild_reactions=True)
|
||||||
intents.members = True
|
|
||||||
|
|
||||||
client = MyClient(intents=intents)
|
client = MyClient(intents=intents)
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -13,5 +13,5 @@ class MyClient(discord.Client):
|
|||||||
if message.content.startswith('!hello'):
|
if message.content.startswith('!hello'):
|
||||||
await message.reply('Hello!', mention_author=True)
|
await message.reply('Hello!', mention_author=True)
|
||||||
|
|
||||||
client = MyClient()
|
client = MyClient(intents=discord.Intents(guilds=True, messages=True))
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@@ -3,7 +3,11 @@ import typing
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned, description="Nothing to see here!")
|
bot = commands.Bot(
|
||||||
|
command_prefix=commands.when_mentioned,
|
||||||
|
description="Nothing to see here!",
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
# the `hidden` keyword argument hides it from the help command.
|
# the `hidden` keyword argument hides it from the help command.
|
||||||
@bot.group(hidden=True)
|
@bot.group(hidden=True)
|
||||||
|
@@ -5,7 +5,10 @@ import discord
|
|||||||
|
|
||||||
class Bot(commands.Bot):
|
class Bot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('$'),
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@@ -5,7 +5,10 @@ import discord
|
|||||||
|
|
||||||
class CounterBot(commands.Bot):
|
class CounterBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('$'),
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
import typing
|
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
@@ -39,7 +37,10 @@ class DropdownView(discord.ui.View):
|
|||||||
|
|
||||||
class Bot(commands.Bot):
|
class Bot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('$'),
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@@ -4,7 +4,10 @@ import discord
|
|||||||
|
|
||||||
class EphemeralCounterBot(commands.Bot):
|
class EphemeralCounterBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('$'),
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@@ -5,7 +5,10 @@ from urllib.parse import quote_plus
|
|||||||
|
|
||||||
class GoogleBot(commands.Bot):
|
class GoogleBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('$'),
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
@@ -36,4 +39,4 @@ async def google(ctx: commands.Context, *, query: str):
|
|||||||
await ctx.send(f'Google Result for: `{query}`', view=Google(query))
|
await ctx.send(f'Google Result for: `{query}`', view=Google(query))
|
||||||
|
|
||||||
|
|
||||||
bot.run('token')
|
bot.run()
|
||||||
|
@@ -29,7 +29,11 @@ class PersistentView(discord.ui.View):
|
|||||||
|
|
||||||
class PersistentViewBot(commands.Bot):
|
class PersistentViewBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('$'),
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
self.persistent_views_added = False
|
self.persistent_views_added = False
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
|
@@ -120,7 +120,10 @@ class TicTacToe(discord.ui.View):
|
|||||||
|
|
||||||
class TicTacToeBot(commands.Bot):
|
class TicTacToeBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('$'),
|
||||||
|
intents=discord.Intents(guilds=True, messages=True)
|
||||||
|
)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
Reference in New Issue
Block a user