简体   繁体   English

Discord.py ctx 命令没有响应

[英]Discord.py ctx commands not responding

None of my ctx commands work.我的 ctx 命令都不起作用。 Here I'll give an example.这里我举个例子。 When I say p!test I want it to print hi and say test , but it's not responding.当我说p!test我希望它打印hi并说test ,但它没有响应。 Can someone help?有人可以帮忙吗?

@client.command()
async def test(ctx):
    print('hi')
    await ctx.channel.send('test')

If you're using a on_message event, you have to 'process commands' in the last line of the event.如果您使用on_message事件,则必须在事件的最后一行“处理命令”。 Otherwise, your commands won't work.否则,您的命令将不起作用。

@client.event
async def on_message(message):
    ...
    await client.process_commands(message)

Reference参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM