Spaces:
Running
Running
Try to get parameters from the callback dynamic_command
Browse files- discord_bot.py +3 -3
discord_bot.py
CHANGED
@@ -121,7 +121,8 @@ async def generateStatus(id: str):
|
|
121 |
|
122 |
# 根据 json 数据动态创建命令
|
123 |
for command in json_data["command"]:
|
124 |
-
async def dynamic_command(interaction: discord.Interaction):
|
|
|
125 |
await interaction.response.defer()
|
126 |
# 动态调用命令对应的函数
|
127 |
function_name = command["function"]
|
@@ -139,8 +140,7 @@ for command in json_data["command"]:
|
|
139 |
tree_command = app_commands.Command(
|
140 |
name=command["name"],
|
141 |
description=command["description"],
|
142 |
-
callback=dynamic_command
|
143 |
-
parameters=[]
|
144 |
)
|
145 |
|
146 |
# 将命令添加到 bot 的 command tree
|
|
|
121 |
|
122 |
# 根据 json 数据动态创建命令
|
123 |
for command in json_data["command"]:
|
124 |
+
async def dynamic_command(interaction: discord.Interaction, **kwargs):
|
125 |
+
print(kwargs)
|
126 |
await interaction.response.defer()
|
127 |
# 动态调用命令对应的函数
|
128 |
function_name = command["function"]
|
|
|
140 |
tree_command = app_commands.Command(
|
141 |
name=command["name"],
|
142 |
description=command["description"],
|
143 |
+
callback=dynamic_command
|
|
|
144 |
)
|
145 |
|
146 |
# 将命令添加到 bot 的 command tree
|