【发布时间】:2021-05-08 07:04:54
【问题描述】:
我希望我的 discord 机器人在我执行某个命令时发送我电脑上的 mp3 文件。 假设命令是 -hello 当我说 -hello 时,我希望机器人在我的电脑上发送一个名为“hello”的 mp3 文件
我该怎么做?
【问题讨论】:
标签: python discord bots discord.py
我希望我的 discord 机器人在我执行某个命令时发送我电脑上的 mp3 文件。 假设命令是 -hello 当我说 -hello 时,我希望机器人在我的电脑上发送一个名为“hello”的 mp3 文件
我该怎么做?
【问题讨论】:
标签: python discord bots discord.py
在此处查看此答案:Discord.py Bot sending file to Discord Channel 如果您想在邮件中附加文件,请使用
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')
【讨论】: