Skip to content

Commit 7bd62a4

Browse files
authored
Updatet main-tree to 1.7.5
1 parent 3001cc3 commit 7bd62a4

File tree

11 files changed

+734
-299
lines changed

11 files changed

+734
-299
lines changed

discord/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
from .role import Role, RoleTags
4242
from .file import File
4343
from .colour import Color, Colour
44-
from .integrations import Integration, IntegrationAccount
44+
from .integrations import Integration, IntegrationAccount, BotIntegration, IntegrationApplication, StreamIntegration
45+
from .interactions import Interaction, ButtonClick, SelectionSelect
4546
from .invite import Invite, PartialInviteChannel, PartialInviteGuild
4647
from .template import Template
4748
from .widget import Widget, WidgetMember, WidgetChannel
@@ -50,7 +51,7 @@
5051
from . import utils, opus, abc
5152
from .enums import *
5253
from .embeds import Embed
53-
from .components import Button, DropdownMenue, ActionRow, ButtonColor, ButtonStyle
54+
from .components import Button, SelectionMenu, ActionRow, ButtonColor, ButtonStyle, select_option
5455
from .mentions import AllowedMentions
5556
from .shard import AutoShardedClient, ShardInfo
5657
from .player import *

discord/abc.py

Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from .role import Role
4141
from .invite import Invite
4242
from .file import File
43-
from .components import Button, DropdownMenue, ActionRow
43+
from .components import Button, SelectionMenu, ActionRow
4444
from .voice_client import VoiceClient, VoiceProtocol
4545
from . import utils
4646

@@ -933,10 +933,10 @@ class Messageable(metaclass=abc.ABCMeta):
933933
async def _get_channel(self):
934934
raise NotImplementedError
935935

936-
async def send(self, content=None, *, tts=False, embed=None, components=None, file=None,
936+
async def send(self, content=None, *, tts=False, embed=None, embeds=None, components=None, file=None,
937937
files=None, delete_after=None, nonce=None,
938938
allowed_mentions=None, reference=None,
939-
mention_author=None):
939+
mention_author=None, hidden=None, **kwargs):
940940
"""|coro|
941941
942942
Sends a message to the destination with the content given.
@@ -997,6 +997,10 @@ async def send(self, content=None, *, tts=False, embed=None, components=None, fi
997997
998998
.. versionadded:: 1.6
999999
1000+
hidden: Optional[:class:`bool`]
1001+
If :bool:`True` the message will be only bee visible for the performer of the interaction.
1002+
If this isnt called within an :class:`RawInteractionCreateEvent` it will be ignored
1003+
10001004
Raises
10011005
--------
10021006
~discord.HTTPException
@@ -1027,12 +1031,12 @@ async def send(self, content=None, *, tts=False, embed=None, components=None, fi
10271031
for component in ([components] if not isinstance(components, list) else components):
10281032
if isinstance(component, Button):
10291033
_components.extend(ActionRow(component).sendable())
1030-
elif isinstance(component, DropdownMenue):
1031-
_components.append(component.to_dict())
1034+
elif isinstance(component, SelectionMenu):
1035+
_components.extend(ActionRow(component).sendable())
10321036
elif isinstance(component, ActionRow):
10331037
_components.extend(component.sendable())
10341038
elif isinstance(component, list):
1035-
_components.extend(ActionRow(*[obj for obj in component if isinstance(obj, Button)]).sendable())
1039+
_components.extend(ActionRow(*[obj for obj in component if any([isinstance(obj, Button), isinstance(obj, SelectionMenu)])]).sendable())
10361040
components = _components
10371041

10381042
if allowed_mentions is not None:
@@ -1056,14 +1060,47 @@ async def send(self, content=None, *, tts=False, embed=None, components=None, fi
10561060
if file is not None and files is not None:
10571061
raise InvalidArgument('cannot pass both file and files parameter to send()')
10581062

1063+
is_interaction_responce = kwargs.pop('__is_interaction_responce', None)
1064+
deferred = kwargs.pop('__deferred', False)
1065+
use_webhook = kwargs.pop('__use_webhook', False)
1066+
interaction_id = kwargs.pop('__interaction_id', None)
1067+
interaction_token = kwargs.pop('__interaction_token', None)
1068+
application_id = kwargs.pop('__application_id', None)
1069+
followup = kwargs.pop('followup', False)
1070+
if is_interaction_responce is False or None:
1071+
hidden = None
1072+
if hidden is not None:
1073+
embedlist = []
1074+
if embed:
1075+
embedlist.append(embed.to_dict())
1076+
if embeds:
1077+
embedlist.extend([e.to_dict() for e in embeds])
1078+
embeds = embedlist
1079+
if len(embeds) > 10:
1080+
raise InvalidArgument(f'The maximum number of embeds that can be sent with a response is 10, get: {len(embeds)}')
1081+
elif embeds:
1082+
raise InvalidArgument('Normal Messages dont support multible Embeds.')
10591083
if file is not None:
10601084
if not isinstance(file, File):
10611085
raise InvalidArgument('file parameter must be File')
10621086

10631087
try:
1064-
data = await state.http.send_files(channel.id, files=[file], allowed_mentions=allowed_mentions,
1065-
content=content, tts=tts, embed=embed, components=components,
1066-
nonce=nonce, message_reference=reference)
1088+
if hidden is not None:
1089+
data = await state.http.send_interaction_response(use_webhook=use_webhook,
1090+
interaction_id=interaction_id,
1091+
token=interaction_token,
1092+
application_id=application_id,
1093+
deferred=deferred,
1094+
files=[file], allowed_mentions=allowed_mentions,
1095+
content=content, tts=tts, embeds=embeds,
1096+
components=components,
1097+
nonce=nonce, message_reference=reference,
1098+
flags=64 if hidden else None,
1099+
followup=followup)
1100+
else:
1101+
data = await state.http.send_files(channel.id, files=[file], allowed_mentions=allowed_mentions,
1102+
content=content, tts=tts, embed=embed, components=components,
1103+
nonce=nonce, message_reference=reference)
10671104
finally:
10681105
file.close()
10691106

@@ -1074,21 +1111,48 @@ async def send(self, content=None, *, tts=False, embed=None, components=None, fi
10741111
raise InvalidArgument('files parameter must be a list of File')
10751112

10761113
try:
1077-
data = await state.http.send_files(channel.id, files=files, content=content, tts=tts,
1078-
embed=embed, components=components, nonce=nonce,
1079-
allowed_mentions=allowed_mentions, message_reference=reference)
1114+
if hidden is not None:
1115+
data = await state.http.send_interaction_response(use_webhook=use_webhook,
1116+
interaction_id=interaction_id,
1117+
token=interaction_token,
1118+
application_id=application_id,
1119+
deferred=deferred,
1120+
files=file, allowed_mentions=allowed_mentions,
1121+
content=content, tts=tts, embeds=embeds,
1122+
components=components,
1123+
nonce=nonce, message_reference=reference,
1124+
flags=64 if hidden else None,
1125+
followup=followup)
1126+
else:
1127+
data = await state.http.send_files(channel.id, files=files, content=content, tts=tts,
1128+
embeds=embeds, components=components, nonce=nonce,
1129+
allowed_mentions=allowed_mentions, message_reference=reference)
10801130
finally:
10811131
for f in files:
10821132
f.close()
10831133
else:
1084-
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, components=components,
1085-
nonce=nonce, allowed_mentions=allowed_mentions,
1086-
message_reference=reference)
1087-
1088-
ret = state.create_message(channel=channel, data=data)
1089-
if delete_after is not None:
1090-
await ret.delete(delay=delete_after)
1091-
return ret
1134+
if hidden is not None:
1135+
data = await state.http.send_interaction_response(use_webhook=use_webhook,
1136+
interaction_id=interaction_id,
1137+
token=interaction_token,
1138+
application_id=application_id,
1139+
deferred=deferred, allowed_mentions=allowed_mentions,
1140+
content=content, tts=tts, embeds=embeds,
1141+
components=components,
1142+
nonce=nonce, message_reference=reference,
1143+
flags=64 if hidden else None,
1144+
followup=followup)
1145+
else:
1146+
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, components=components,
1147+
nonce=nonce, allowed_mentions=allowed_mentions,
1148+
message_reference=reference)
1149+
1150+
if not hidden is True and isinstance(data, dict):
1151+
ret = state.create_message(channel=channel, data=data)
1152+
if delete_after is not None and hidden is None:
1153+
await ret.delete(delay=delete_after)
1154+
return ret
1155+
return None
10921156

10931157
async def trigger_typing(self):
10941158
"""|coro|

discord/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,6 @@ def check(reaction, user):
976976
def _check(*args):
977977
return True
978978
check = _check
979-
980979
ev = event.lower()
981980
try:
982981
listeners = self._listeners[ev]

0 commit comments

Comments
 (0)