这是我的代码:
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)
这是我第一次尝试制作一个不和谐的机器人,所以请简单地解释一下。我不确定为了为机器人创建斜杠命令我做错了什么。 非常感谢
我运行了它,控制台打印出“就绪!” 没有迹象表明它与我按下/
不和谐您确定您的机器人何时上线? 因为代码对我来说工作得很好。