discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
985 stars 236 forks source link

Type 1 slash command trouble #969

Closed TimLiz closed 1 year ago

TimLiz commented 1 year ago

Environment

Describe the bug Type 1 command trouble

Working one

$cmd = new Command($discord, ['name' => 'ping', 'description' => 'Pong!']);
$discord->application->commands->save($cmd);

Not working one

$cmd = new Command($discord);
$cmd->setType(Command::CHAT_INPUT);
$cmd->setName("ping");
$discord->application->commands->save($cmd);

Also, it is works fine for type 3 command

$cmd = new Command($discord);
$cmd->setType(Command::MESSAGE);
$cmd->setName("Ответить");
$discord->application->commands->save($cmd);

Error

Bad Request - {     "code": 50035,     "errors": {         "description": {             "_errors": [                 {                     "code": "BASE_TYPE_REQUIRED",                     "message": "This field is required"                 }             ]         }     },     "message": "Invalid Form Body" }
SQKo commented 1 year ago

Slash command (type CHAT_INPUT) requires description, in which you missed $cmd->setDescription('Pong!') in the 2nd code.

Message context menu (type MESSAGE) doesn't require a description