如何使用 discord.py 让我的机器人在语音频道中播放 mp3?

时间:2021-02-23 09:46:08

标签: python discord.py

我找到了这个帖子:How do I make my discord.py bot play mp3 in voice channel?

但不幸的是它已经过时并且不再起作用了。 我的代码:

user = message.author

    voice_channel = user.voice.voice_channel
    channel = None

    if voice_channel != None:
        channel=voice_channel.name
        await channel.send('User is in channel: '+ channel)
        vc = await channel.join(channel)
        player = vc.create_ffmpeg_player('Gdzie-ona-jest_.mp3', after=lambda: print('done'))
        player.start()
        while not player.is_done():
            await asyncio.sleep(1)

    player.stop()
    await vc.disconnect()
else:
    await channel.send('User is not in a channel.')

希望你能帮助我,干杯!!

0 个答案:

没有答案