制作一个不和谐的机器人来使用斜线命令,这里有什么问题吗?我在服务器中看不到该命令

问题描述 投票:0回答:1

这是我的代码:

from typing import Final
import os
from dotenv import load_dotenv
import discord
from discord import Intents, Client, Message, app_commands

load_dotenv()
TOKEN: Final[str] = os.getenv("BOT_TOKEN")

intents = Intents.default()
client = Client(intents=intents)
tree = app_commands.CommandTree(client)

@tree.command(
    name="commandname",
    description="My first application Command",
)
async def first_command(interaction):
    await interaction.response.send_message("Hello!")
    
@client.event
async def on_ready():
    await tree.sync()
    print("Ready!")
    
client.run(TOKEN)

这是我第一次尝试制作一个不和谐的机器人,所以请简单地解释一下。我不确定为了为机器人创建斜杠命令我做错了什么。 非常感谢

我运行了它,控制台打印出“就绪!” 没有迹象表明它与我按下/

不和谐
python discord discord.py
1个回答
0
投票

您确定您的机器人何时上线? 因为代码对我来说工作得很好。

© www.soinside.com 2019 - 2024. All rights reserved.