Skip to content

Commit 68492e1

Browse files
authored
feat: warn users when they try and send attachments as files (#1450)
1 parent 59f5030 commit 68492e1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

interactions/client/mixins/send.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import TYPE_CHECKING, Any, Iterable, Optional, Union
22

33
import interactions.models as models
4+
import interactions.models.discord
45
from interactions.models.discord.enums import MessageFlags
56

67
if TYPE_CHECKING:
@@ -82,6 +83,18 @@ async def send(
8283
flags = MessageFlags(flags)
8384
flags = flags | MessageFlags.SILENT
8485

86+
if (
87+
files
88+
and (
89+
isinstance(files, Iterable)
90+
and any(isinstance(file, interactions.models.discord.message.Attachment) for file in files)
91+
)
92+
or isinstance(files, interactions.models.discord.message.Attachment)
93+
):
94+
raise ValueError(
95+
"Attachments are not files. Attachments only contain metadata about the file, not the file itself - to send an attachment, you need to download it first. Check Attachment.url"
96+
)
97+
8598
message_payload = models.discord.message.process_message_payload(
8699
content=content,
87100
embeds=embeds or embed,

0 commit comments

Comments
 (0)