【问题标题】:How can I get my discord bot to send mp3 files? (discord.py)如何让我的不和谐机器人发送 mp3 文件? (discord.py)
【发布时间】:2021-05-08 07:04:54
【问题描述】:

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

我该怎么做?

【问题讨论】:

    标签: python discord bots discord.py


    【解决方案1】:

    在此处查看此答案:Discord.py Bot sending file to Discord Channel 如果您想在邮件中附加文件,请使用

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

    【讨论】:

      【解决方案2】:

      这是使用 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')
      

      【讨论】:

        猜你喜欢
        • 2021-04-27
        • 1970-01-01
        • 2020-10-01
        • 1970-01-01
        • 2021-08-17
        • 2021-06-04
        • 2018-08-05
        • 2020-12-26
        • 2021-04-25
        相关资源
        最近更新 更多