Discord.py命令前缀不调用命令?
我一直在努力解决这个问题,但我的机器人的discord.py命令前缀似乎不起作用。目前,我的代码如下:Discord.py命令前缀不调用命令?,discord.py,Discord.py,我一直在努力解决这个问题,但我的机器人的discord.py命令前缀似乎不起作用。目前,我的代码如下: players = {} client = commands.Bot(command_prefix = "!") @client.event async def on_ready(): print(f'{client.user} has connected to Discord!') await client.change_presence(activi
players = {}
client = commands.Bot(command_prefix = "!")
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
await client.change_presence(activity=discord.Game(name="with your words!"))
called_once_an_hour.start()
@client.command()
async def test():
await client.send('test')
@client.command(pass_context = True)
async def join(ctx):
channel = ctx.message.author.voice.voice_channel
await client.join_voice_channel(channel)
@client.command(pass_context = True)
async def leave(ctx):
server = ctx.message.server
voice_client = client.voice_client_in(server)
await voice_client.disconnect()
@client.command(pass_context = True)
async def play(ctx):
server = ctx.message.server
voice_client = client.voice_client_in(server)
player = await voice_client.create_ytdl_player('https://www.youtube.com/watch?v=YMw-9mXfccY')
players[server.id] = player
player.start()
print(f"Playing Are you winning son in server voice client: {voice_client}")
第一个客户机命令主要用于调试目的,但它从未被调用。
我还认为我已经具备了所有必要的导入功能您的测试命令需要如下所示:
async def test(ctx):
await ctx.send('test')
我可以用成功地运行它!测试
默认情况下传递上下文,pass\u context=True
不再需要
请参阅命令文档:您好!谢谢你的回复。虽然它似乎对你有用,但对我却不合适。也许我当前的编码中有什么东西干扰了我的命令前缀?我可以发送整个编码块,如果你想知道什么是错误的,这里正是我正在运行的:,我想指出,test命令是唯一可以在这里工作的命令。无论您在何处复制此代码表单,都会使用discord.py的预重写版本,因此如果希望它正常工作,您必须对其进行现代化。