You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

discord.py斜杠命令同步失败:执行sync命令后未生效问题排查

Discord机器人斜杠命令同步无效问题

我正在尝试为我的Discord机器人同步所有斜杠命令,但运行sync命令后未生效。

我的client变量创建代码如下:

client = commands.Bot(intents=INTENTS, command_prefix=PREFIX)

同步命令代码:

@client.command()
async def sync(ctx):
    print("sync command")
    if ctx.author.id == my_id:
        await client.tree.sync()
        await ctx.send('Command tree synced.')
    else:
        await ctx.send('You must be the owner to use this command!')

运行该命令后我能收到返回消息,说明tree.sync()已执行,但似乎没有效果。请问同步是否需要等待时间,还是代码写法有误?另外,尝试await client.tree.sync(guild=None)也无效。

内容的提问来源于stack exchange,提问作者Zye

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 21:34:55