我正在尝试编写一个不和谐的音乐机器人,但经过数小时的搜索和不同的教程,我无法让它工作。到目前为止,这是我的代码:
import discord
from discord.ext import commands
import os
client = commands.Bot(command_prefix="!")
@client.command()
async def music(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='Music')
await voiceChannel.connect()
await voice.connect()
voice.play(discord.FFmpegPCMAudio("song.mp3"))
client.run('TOKEN')
当我运行机器人时,它加入了语音频道,但不播放任何音乐
我尝试了很多方法,但都行不通。我听说它与 discord.utils.get(client.voice_clients, guild=ctx.guild)
有关,但我似乎找不到替代方案。
(我知道网上有答案,但它们对我不起作用)
请帮忙
谢谢,哈尼尔