Skip to content

Commit 21c2985

Browse files
committed
Allow pass dict
1 parent c89580c commit 21c2985

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

interactions/api/http/message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def send_message(
2626
tts: bool = False,
2727
embeds: Optional[List[Embed]] = None,
2828
nonce: Union[int, str] = None,
29-
allowed_mentions: Optional[AllowedMentions] = None,
29+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = None,
3030
message_reference: Optional[Message] = None,
3131
stickers: Optional[List[Sticker]] = None,
3232
) -> dict:
@@ -49,7 +49,7 @@ async def send_message(
4949
payload["nonce"] = nonce
5050

5151
if allowed_mentions:
52-
payload["allowed_mentions"] = allowed_mentions._json
52+
payload["allowed_mentions"] = allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
5353

5454
if message_reference:
5555
payload["message_reference"] = message_reference

interactions/api/models/channel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async def send(
197197
attachments: Optional[List["Attachment"]] = MISSING,
198198
files: Optional[Union[File, List[File]]] = MISSING,
199199
embeds: Optional[Union["Embed", List["Embed"]]] = MISSING,
200-
allowed_mentions: Optional[AllowedMentions] = MISSING,
200+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
201201
stickers: Optional[List["Sticker"]] = MISSING,
202202
components: Optional[
203203
Union[
@@ -224,7 +224,7 @@ async def send(
224224
:param embeds?: An embed, or list of embeds for the message.
225225
:type embeds?: Optional[Union[Embed, List[Embed]]]
226226
:param allowed_mentions?: The allowed mentions for the message.
227-
:type allowed_mentions?: Optional[AllowedMentions]
227+
:type allowed_mentions?: Optional[Union[AllowedMentions, dict]]
228228
:param stickers?: A list of stickers to send with your message. You can send up to 3 stickers per message.
229229
:type stickers?: Optional[List[Sticker]]
230230
:param components?: A component, or list of components for the message.
@@ -240,7 +240,7 @@ async def send(
240240
_content: str = "" if content is MISSING else content
241241
_tts: bool = False if tts is MISSING else tts
242242
_attachments = [] if attachments is MISSING else [a._json for a in attachments]
243-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
243+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
244244
_sticker_ids: list = (
245245
[] if stickers is MISSING else [str(sticker.id) for sticker in stickers]
246246
)

interactions/api/models/gw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ async def send(
418418
tts: Optional[bool] = MISSING,
419419
files: Optional[Union[File, List[File]]] = MISSING,
420420
embeds: Optional[Union[Embed, List[Embed]]] = MISSING,
421-
allowed_mentions: Optional[AllowedMentions] = MISSING,
421+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
422422
) -> Message:
423423
"""
424424
Sends a DM to the member.
@@ -434,7 +434,7 @@ async def send(
434434
:param embeds?: An embed, or list of embeds for the message.
435435
:type embeds?: Optional[Union[Embed, List[Embed]]]
436436
:param allowed_mentions?: The allowed mentions for the message.
437-
:type allowed_mentions?: Optional[AllowedMentions]
437+
:type allowed_mentions?: Optional[Union[AllowedMentions, dict]]
438438
:return: The sent message as an object.
439439
:rtype: Message
440440
"""
@@ -450,7 +450,7 @@ async def send(
450450
if not embeds or embeds is MISSING
451451
else ([embed._json for embed in embeds] if isinstance(embeds, list) else [embeds._json])
452452
)
453-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
453+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
454454
if not components or components is MISSING:
455455
_components = []
456456
else:

interactions/api/models/member.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ async def send(
222222
attachments: Optional[List["Attachment"]] = MISSING,
223223
files: Optional[Union[File, List[File]]] = MISSING,
224224
embeds: Optional[Union["Embed", List["Embed"]]] = MISSING,
225-
allowed_mentions: Optional[AllowedMentions] = MISSING,
225+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
226226
) -> "Message":
227227
"""
228228
Sends a DM to the member.
@@ -240,7 +240,7 @@ async def send(
240240
:param embeds?: An embed, or list of embeds for the message.
241241
:type embeds?: Optional[Union[Embed, List[Embed]]]
242242
:param allowed_mentions?: The allowed mentions for the message.
243-
:type allowed_mentions?: Optional[AllowedMentions]
243+
:type allowed_mentions?: Optional[Union[AllowedMentions, dict]]
244244
:return: The sent message as an object.
245245
:rtype: Message
246246
"""
@@ -257,7 +257,7 @@ async def send(
257257
if not embeds or embeds is MISSING
258258
else ([embed._json for embed in embeds] if isinstance(embeds, list) else [embeds._json])
259259
)
260-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
260+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
261261
if not components or components is MISSING:
262262
_components = []
263263
else:

interactions/api/models/message.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ async def edit(
828828
files: Optional[Union[File, List[File]]] = MISSING,
829829
embeds: Optional[Union["Embed", List["Embed"]]] = MISSING,
830830
suppress_embeds: Optional[bool] = MISSING,
831-
allowed_mentions: Optional[AllowedMentions] = MISSING,
831+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
832832
message_reference: Optional[MessageReference] = MISSING,
833833
attachments: Optional[List["Attachment"]] = MISSING,
834834
components: Optional[
@@ -856,7 +856,7 @@ async def edit(
856856
:param suppress_embeds?: Whether to suppress embeds in the message.
857857
:type suppress_embeds?: Optional[bool]
858858
:param allowed_mentions?: The allowed mentions for the message.
859-
:type allowed_mentions?: Optional[AllowedMentions]
859+
:type allowed_mentions?: Optional[Union[AllowedMentions, dict]]
860860
:param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first
861861
:type attachments?: Optional[List[Attachment]]
862862
:param components?: A component, or list of components for the message. If `[]` the components will be removed
@@ -904,7 +904,7 @@ async def edit(
904904
else []
905905
)
906906

907-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
907+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
908908
_message_reference: dict = {} if message_reference is MISSING else message_reference._json
909909
if not components:
910910
_components = []
@@ -943,7 +943,7 @@ async def reply(
943943
embeds: Optional[Union["Embed", List["Embed"]]] = MISSING,
944944
files: Optional[Union[File, List[File]]] = MISSING,
945945
attachments: Optional[List["Attachment"]] = MISSING,
946-
allowed_mentions: Optional[AllowedMentions] = MISSING,
946+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
947947
stickers: Optional[List["Sticker"]] = MISSING,
948948
components: Optional[
949949
Union[
@@ -970,7 +970,7 @@ async def reply(
970970
:param embeds?: An embed, or list of embeds for the message.
971971
:type embeds?: Optional[Union[Embed, List[Embed]]]
972972
:param allowed_mentions?: The allowed mentions for the message.
973-
:type allowed_mentions?: Optional[AllowedMentions]
973+
:type allowed_mentions?: Optional[Union[AllowedMentions, dict]]
974974
:param components?: A component, or list of components for the message.
975975
:type components?: Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]]
976976
:param stickers?: A list of stickers to send with your message. You can send up to 3 stickers per message.
@@ -991,7 +991,7 @@ async def reply(
991991
if not embeds or embeds is MISSING
992992
else ([embed._json for embed in embeds] if isinstance(embeds, list) else [embeds._json])
993993
)
994-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
994+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
995995
_message_reference = MessageReference(message_id=int(self.id))._json
996996
_attachments = [] if attachments is MISSING else [a._json for a in attachments]
997997
if not components or components is MISSING:

interactions/api/models/webhook.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async def execute(
180180
avatar_url: Optional[str] = MISSING,
181181
tts: Optional[bool] = MISSING,
182182
embeds: Optional[Union["Embed", List["Embed"]]] = MISSING,
183-
allowed_mentions: Optional[AllowedMentions] = MISSING,
183+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
184184
attachments: Optional[List["Attachment"]] = MISSING,
185185
components: Optional[
186186
Union[
@@ -214,7 +214,7 @@ async def execute(
214214
:param embeds: embedded ``rich`` content
215215
:type embeds: Union[Embed, List[Embed]]
216216
:param allowed_mentions?: The allowed mentions for the message.
217-
:type allowed_mentions?: Optional[AllowedMentions]
217+
:type allowed_mentions?: Optional[Union[AllowedMentions, dict]]
218218
:param components: the components to include with the message
219219
:type components: Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]
220220
:param files: The files to attach to the message
@@ -240,7 +240,7 @@ async def execute(
240240
if not embeds or embeds is MISSING
241241
else ([embed._json for embed in embeds] if isinstance(embeds, list) else [embeds._json])
242242
)
243-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
243+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
244244

245245
if not components or components is MISSING:
246246
_components = []

interactions/client/context.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async def send(
109109
tts: Optional[bool] = MISSING,
110110
attachments: Optional[List[Attachment]] = MISSING,
111111
embeds: Optional[Union[Embed, List[Embed]]] = MISSING,
112-
allowed_mentions: Optional[AllowedMentions] = MISSING,
112+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
113113
components: Optional[
114114
Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]
115115
] = MISSING,
@@ -128,7 +128,7 @@ async def send(
128128
:param embeds?: An embed, or list of embeds for the message.
129129
:type embeds?: Optional[Union[Embed, List[Embed]]]
130130
:param allowed_mentions?: The allowed mentions for the message.
131-
:type allowed_mentions?: Optional[AllowedMentions]
131+
:type allowed_mentions?: Optional[Union[AllowedMentions, dict]]
132132
:param components?: A component, or list of components for the message.
133133
:type components?: Optional[Union[ActionRow, Button, SelectMenu, List[Union[ActionRow, Button, SelectMenu]]]]
134134
:param ephemeral?: Whether the response is hidden or not.
@@ -157,7 +157,7 @@ async def send(
157157
if not embeds or embeds is MISSING
158158
else ([embed._json for embed in embeds] if isinstance(embeds, list) else [embeds._json])
159159
)
160-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
160+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
161161

162162
if components is not MISSING and components:
163163
# components could be not missing but an empty list
@@ -198,7 +198,7 @@ async def edit(
198198
tts: Optional[bool] = MISSING,
199199
attachments: Optional[List[Attachment]] = MISSING,
200200
embeds: Optional[Union[Embed, List[Embed]]] = MISSING,
201-
allowed_mentions: Optional[AllowedMentions] = MISSING,
201+
allowed_mentions: Optional[Union[AllowedMentions, dict]] = MISSING,
202202
message_reference: Optional[MessageReference] = MISSING,
203203
components: Optional[
204204
Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]
@@ -247,7 +247,7 @@ async def edit(
247247

248248
payload["attachments"] = _attachments
249249

250-
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json
250+
_allowed_mentions: dict = {} if allowed_mentions is MISSING else allowed_mentions._json if isinstance(allowed_mentions, AllowedMentions) else allowed_mentions
251251
_message_reference: dict = {} if message_reference is MISSING else message_reference._json
252252

253253
payload["allowed_mentions"] = _allowed_mentions

0 commit comments

Comments
 (0)