Spaces:
Running
Running
Fixed: 'await' outside async function
Browse files- discord_bot.py +7 -3
discord_bot.py
CHANGED
@@ -150,9 +150,13 @@ for command in json_data["command"]:
|
|
150 |
|
151 |
|
152 |
class Test:
|
153 |
-
def __init__(self,
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
156 |
def test(self, inter, x: str, y: int):
|
157 |
print(self)
|
158 |
print(inter)
|
|
|
150 |
|
151 |
|
152 |
class Test:
|
153 |
+
def __init__(self, *args, **kwargs):
|
154 |
+
super().__init__(*args, **kwargs)
|
155 |
+
self.tree = app_commands.CommandTree(self)
|
156 |
+
async def setup_hook(self):
|
157 |
+
# 在这里你可以注册动态生成的命令
|
158 |
+
self.tree.add_command(app_commands.Command(name="test", callback=self.test, description="test"))
|
159 |
+
await self.tree.sync() # 同步命令
|
160 |
def test(self, inter, x: str, y: int):
|
161 |
print(self)
|
162 |
print(inter)
|