Merge pull request #1367 from CyberL1/fix/application-commands-options-default
Default command options to `[]`, send `options` only for type 1
This commit is contained in:
commit
90ca2c2359
@ -20,7 +20,7 @@ import { route } from "@spacebar/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Application, ApplicationCommand, Member, Snowflake } from "@spacebar/util";
|
||||
import { IsNull } from "typeorm";
|
||||
import { ApplicationCommandSchema } from "@spacebar/schemas";
|
||||
import { ApplicationCommandSchema, ApplicationCommandType } from "@spacebar/schemas";
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
|
||||
@ -67,7 +67,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
description: command.description,
|
||||
description_localizations: command.description_localizations,
|
||||
// description_localized: // TODO: make this work
|
||||
options: command.options,
|
||||
options: command.type === ApplicationCommandType.CHAT_INPUT ? command.options : undefined,
|
||||
default_member_permissions: command.default_member_permissions,
|
||||
dm_permission: command.dm_permission,
|
||||
permissions: command.permissions,
|
||||
|
||||
@ -53,8 +53,8 @@ export class ApplicationCommand extends BaseClass {
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
description_localizations?: Record<string, string>;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
options?: ApplicationCommandOption[];
|
||||
@Column({ type: "simple-json", default: [] })
|
||||
options: ApplicationCommandOption[];
|
||||
|
||||
@Column({ nullable: true, type: String })
|
||||
default_member_permissions: string | null;
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class ApplicationCommandsOptionsDefault1761209437070 implements MigrationInterface {
|
||||
name = "ApplicationCommandsOptionsDefault1761209437070";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`UPDATE "application_commands" SET "options" = '[]' WHERE "options" IS NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" SET DEFAULT '[]'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" DROP DEFAULT`);
|
||||
await queryRunner.query(`ALTER TABLE "application_commands" ALTER COLUMN "options" DROP NOT NULL`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user