在不和谐嵌入中发送多个文件 - discord.py
Sending multiple files in discord Embed - discord.py
目前,我已通过 link(下图)发送文件,但出于安全原因我不能再发送了。
我的第一个想法是在不同的消息中一次发送一个文件,但我不喜欢它。
那么,有一种方法可以在 Discord 嵌入中发送多个文件(或在一条消息中发送多个文件)吗?
说明
这可以通过创建 discord.File
个对象的列表,然后将其作为 Messageable.send(files=your_list_of_files)
.
传递来完成
我在下面包含了根据文件名打开文件对象列表的代码。
代码
files_to_read: list[str] = []
files_to_send: list[discord.File] = []
for filename in files_to_read:
with open(filename, 'rb') as f: # discord file objects must be opened in binary and read mode
files_to_send.append(discord.File(f))
await {Messageable}.send(files=files_to_send)
参考
目前,我已通过 link(下图)发送文件,但出于安全原因我不能再发送了。
我的第一个想法是在不同的消息中一次发送一个文件,但我不喜欢它。
那么,有一种方法可以在 Discord 嵌入中发送多个文件(或在一条消息中发送多个文件)吗?
说明
这可以通过创建 discord.File
个对象的列表,然后将其作为 Messageable.send(files=your_list_of_files)
.
我在下面包含了根据文件名打开文件对象列表的代码。
代码
files_to_read: list[str] = []
files_to_send: list[discord.File] = []
for filename in files_to_read:
with open(filename, 'rb') as f: # discord file objects must be opened in binary and read mode
files_to_send.append(discord.File(f))
await {Messageable}.send(files=files_to_send)