我正在制作一个discord的机器人,可以获得不同平台上的游戏的玩家数量.我希望能够让它有一个称为/count steam
的命令,它将返回游戏的玩家计数.我已经将其设置为执行此操作,但我不知道如何在斜杠命令中添加空格.我看到其他机器人都有它,所以它是这样的:/command game <arg>
这是我当前的斜杠命令代码(显然我有所有其他机器人的东西):
@bot.tree.command(name="count", description = "Gorilla Tag's steam player count")
async def count_steam(interaction: discord.Interaction):
await interaction.response.send_message(getSteamPlayers())
无论何时运行此命令,我都会收到以下错误:
Traceback (most recent call last):
File "D:\Gorilla Bot\main.py", line 93, in <module>
async def count_steam(interaction: discord.Interaction):
File "C:\Users\Sensor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 887, in decorator
command = Command(
File "C:\Users\Sensor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 644, in __init__
self.name: str = validate_name(name)
File "C:\Users\Sensor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 191, in validate_name
raise ValueError(
ValueError: 'count steam' must be between 1-32 characters and contain only lower-case letters, numbers, hyphens, or underscores.
我使用的是最新版本的discord.py.我还将这些用于不一致模块导入(如果有帮助):
import discord
from discord import app_commands
from discord.ext import commands