<small id='uEMYC'></small><noframes id='uEMYC'>

<i id='uEMYC'><tr id='uEMYC'><dt id='uEMYC'><q id='uEMYC'><span id='uEMYC'><b id='uEMYC'><form id='uEMYC'><ins id='uEMYC'></ins><ul id='uEMYC'></ul><sub id='uEMYC'></sub></form><legend id='uEMYC'></legend><bdo id='uEMYC'><pre id='uEMYC'><center id='uEMYC'></center></pre></bdo></b><th id='uEMYC'></th></span></q></dt></tr></i><div id='uEMYC'><tfoot id='uEMYC'></tfoot><dl id='uEMYC'><fieldset id='uEMYC'></fieldset></dl></div>
        <tfoot id='uEMYC'></tfoot>
        <legend id='uEMYC'><style id='uEMYC'><dir id='uEMYC'><q id='uEMYC'></q></dir></style></legend>
        • <bdo id='uEMYC'></bdo><ul id='uEMYC'></ul>

        Discord.py Bot 如何从本地文件播放音频

        Discord.py Bot How to play audio from local files(Discord.py Bot 如何从本地文件播放音频)
      1. <legend id='dgVYY'><style id='dgVYY'><dir id='dgVYY'><q id='dgVYY'></q></dir></style></legend>
          <tbody id='dgVYY'></tbody>

            <small id='dgVYY'></small><noframes id='dgVYY'>

            <tfoot id='dgVYY'></tfoot>

              • <i id='dgVYY'><tr id='dgVYY'><dt id='dgVYY'><q id='dgVYY'><span id='dgVYY'><b id='dgVYY'><form id='dgVYY'><ins id='dgVYY'></ins><ul id='dgVYY'></ul><sub id='dgVYY'></sub></form><legend id='dgVYY'></legend><bdo id='dgVYY'><pre id='dgVYY'><center id='dgVYY'></center></pre></bdo></b><th id='dgVYY'></th></span></q></dt></tr></i><div id='dgVYY'><tfoot id='dgVYY'></tfoot><dl id='dgVYY'><fieldset id='dgVYY'></fieldset></dl></div>
                • <bdo id='dgVYY'></bdo><ul id='dgVYY'></ul>
                • 本文介绍了Discord.py Bot 如何从本地文件播放音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  基本上是标题.我已经安装了 ffmpeg 和 discord.py[audio].我只需要了解它是如何工作的.找不到本地音频文件的任何教程.而且我无法从文档中理解任何内容:/

                  Basically the title. I installed ffmpeg and discord.py[audio] already. I just need to learn how it works. couldn't find any tutorial for local audio files. and I cant understand anything from documentations :/

                  推荐答案

                  这是一个播放本地音频文件的功能.我在使用 FFmpeg 时遇到了问题,所以我硬编码了 .exe 路径.另外,我本地文件的文件路径有问题,所以我把绝对路径放进去.这个函数也会在音频播放完毕后删除调用它的命令,保持整洁.

                  That's a function that plays a local audio file. I had problems with FFmpeg, so I hardcoded the .exe path. Also, I had a problem with the file path to the local file, so I put the absolute path in. This function also deletes the command that called it after the audio is done playing, keeping things tidy.

                   @bot.command(name="<command_name>")
                      async def <function_name>(ctx):
                          # Gets voice channel of message author
                          voice_channel = ctx.author.channel
                          channel = None
                          if voice_channel != None:
                              channel = voice_channel.name
                              vc = await voice_channel.connect()
                              vc.play(discord.FFmpegPCMAudio(executable="C:/ffmpeg/bin/ffmpeg.exe", source="C:<path_to_file>"))
                              # Sleep while audio is playing.
                              while vc.is_playing():
                                  sleep(.1)
                              await vc.disconnect()
                          else:
                              await ctx.send(str(ctx.author.name) + "is not in a channel.")
                          # Delete command after the audio is done playing.
                          await ctx.message.delete()
                  

                  这篇关于Discord.py Bot 如何从本地文件播放音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  【网站声明】本站部分内容来源于互联网,旨在帮助大家更快的解决问题,如果有图片或者内容侵犯了您的权益,请联系我们删除处理,感谢您的支持!

                  相关文档推荐

                  How to make a discord bot that gives roles in Python?(如何制作一个在 Python 中提供角色的不和谐机器人?)
                  Discord bot isn#39;t responding to commands(Discord 机器人没有响应命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“关于我吗?Discord 机器人的功能?(不和谐.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 机器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自动更改角色颜色)
                  • <tfoot id='yhaXR'></tfoot>
                      <tbody id='yhaXR'></tbody>

                      <i id='yhaXR'><tr id='yhaXR'><dt id='yhaXR'><q id='yhaXR'><span id='yhaXR'><b id='yhaXR'><form id='yhaXR'><ins id='yhaXR'></ins><ul id='yhaXR'></ul><sub id='yhaXR'></sub></form><legend id='yhaXR'></legend><bdo id='yhaXR'><pre id='yhaXR'><center id='yhaXR'></center></pre></bdo></b><th id='yhaXR'></th></span></q></dt></tr></i><div id='yhaXR'><tfoot id='yhaXR'></tfoot><dl id='yhaXR'><fieldset id='yhaXR'></fieldset></dl></div>
                        <bdo id='yhaXR'></bdo><ul id='yhaXR'></ul>
                          • <small id='yhaXR'></small><noframes id='yhaXR'>

                            <legend id='yhaXR'><style id='yhaXR'><dir id='yhaXR'><q id='yhaXR'></q></dir></style></legend>