You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Discord机器人私聊中无法使用斜杠命令的问题求助

Discord机器人私聊中无法使用斜杠命令的问题求助

嘿,各位大佬好!我碰到了一个挺闹心的问题:我的Discord机器人在服务器里能正常调用斜杠命令,但在私聊窗口里完全找不到这些命令——输入/之后,选择菜单里根本不显示机器人的命令选项,完全没法用。

下面是我当前的代码,麻烦大家帮我看看哪里出问题了:

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="/", intents=intents)

@bot.event
async def on_ready():
    try:
        await bot.tree.sync()
        print(f"{bot.user.name} online")
    except Exception as e:
        print(f"Sync error: {e}")

@bot.tree.command(name="ping")
async def ping(ctx):
    await ctx.response.send_message("Pong", ephemeral=True)
    
bot.run("TOKEN")

我已经尝试过重新同步命令,但私聊里还是没法正常使用这些斜杠命令,有没有大佬能帮我排查下问题根源呀?

备注:内容来源于stack exchange,提问作者Olimpiia_ ART

火山引擎 最新活动