【问题标题】:play Youtube audio with python Discord bot使用 python Discord bot 播放 Youtube 音频
【发布时间】:2018-05-17 21:14:53
【问题描述】:

嘿,我想知道是否可以在不做任何特别的事情的情况下播放 youtube 音频。这是我的代码:

if message.content.upper().startswith('!PLAY'):
    args = message.content.split(" ")
    url = args[1]
    author = message.author
    voice_channel = author.voice_channel
    vc = await Client.join_voice_channel(voice_channel)

    player = await vc.create_ytdl_player(url)
    player.Start()

我认为这已经足够了,但我想如果可能的话,没有人有一些关于如何做到这一点的提示吗?

【问题讨论】:

    标签: python audio youtube bots discord


    【解决方案1】:

    也许你应该看一些教程而不是在这里问?我也建议这样做

    @client.command()
    async def yt(ctx, url):
    
        author = ctx.message.author
        voice_channel = author.voice_channel
        vc = await client.join_voice_channel(voice_channel)
    
        player = await vc.create_ytdl_player(url)
        player.start()
    

    虽然我不完全确定,但这应该可以工作:)

    【讨论】:

      猜你喜欢
      • 2021-11-18
      • 2021-10-29
      • 2017-03-05
      • 2020-11-26
      • 1970-01-01
      • 2017-03-12
      • 2021-11-07
      • 2023-03-21
      • 2022-08-20
      相关资源
      最近更新 更多