繁体   English   中英

如何让我的 discord 机器人发送 mp3 文件? (discord.py)

[英]How can I get my discord bot to send mp3 files? (discord.py)

当我执行某个命令时,我希望我的 discord 机器人发送我在我的电脑上拥有的 mp3 文件。 假设命令是 -hello 当我说 -hello 我希望机器人在我的电脑上发送一个名为“hello”的 mp3 文件

我怎么能这样做?

在此处查看此答案: Discord.py Bot 将文件发送到 Discord 频道

await ctx.send(file=discord.File(r'c:\location\of\the_file_to\send.mp3'))

这是使用 gXLg 发送的整个“代码”

from discord.ext import commands

client = commands.Bot(command_prefix='-')

@bot.command()
async def hello(ctx):
 await ctx.send(file=discord.File(r'location\to\file\hello.mp3'))

client.run('your token here')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM