diff --git a/assets/openapi.json b/assets/openapi.json index bb8268f5..d2bc69f3 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/assets/schemas.json b/assets/schemas.json index 3a275201..5a8e17fd 100644 Binary files a/assets/schemas.json and b/assets/schemas.json differ diff --git a/src/api/routes/applications/#application_id/commands/#command_id/index.ts b/src/api/routes/applications/#application_id/commands/#command_id/index.ts index b478fdd5..7907c1ba 100644 --- a/src/api/routes/applications/#application_id/commands/#command_id/index.ts +++ b/src/api/routes/applications/#application_id/commands/#command_id/index.ts @@ -95,7 +95,7 @@ router.patch( version: Snowflake.generate(), }; - await ApplicationCommand.update({ name: body.name }, commandForDb); + await ApplicationCommand.update({ name: body.name.trim() }, commandForDb); res.send(commandForDb); }, ); diff --git a/src/api/routes/applications/#application_id/commands/index.ts b/src/api/routes/applications/#application_id/commands/index.ts index 86057f59..97753f00 100644 --- a/src/api/routes/applications/#application_id/commands/index.ts +++ b/src/api/routes/applications/#application_id/commands/index.ts @@ -83,10 +83,10 @@ router.post( version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: body.name } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: body.name.trim() } }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, name: body.name }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id, name: body.name.trim() }, commandForDb); } else { commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change await ApplicationCommand.save(commandForDb); @@ -99,7 +99,7 @@ router.post( router.put( "/", route({ - // requestBody: "ApplicationCommandCreateSchema", // How to make this array? + requestBody: "BulkApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); @@ -154,10 +154,10 @@ router.put( version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: command.name } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: command.name.trim() } }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, name: command.name }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id, name: command.name.trim() }, commandForDb); } else { commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change await ApplicationCommand.save(commandForDb); diff --git a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts index 94a2171c..2570358d 100644 --- a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts +++ b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts @@ -113,7 +113,7 @@ router.patch( }; const commandExists = await ApplicationCommand.exists({ - where: { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name }, + where: { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name.trim() }, }); if (!commandExists) { @@ -121,7 +121,10 @@ router.patch( return; } - await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name }, commandForDb); + await ApplicationCommand.update( + { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name.trim() }, + commandForDb, + ); res.send(commandForDb); }, ); diff --git a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts index 111c26f4..1639e7be 100644 --- a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts +++ b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts @@ -107,10 +107,10 @@ router.post( version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() } }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() }, commandForDb); } else { commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change await ApplicationCommand.save(commandForDb); @@ -123,7 +123,7 @@ router.post( router.put( "/", route({ - // requestBody: "ApplicationCommandCreateSchema", // How to make this array? + requestBody: "BulkApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); diff --git a/src/api/routes/interactions/index.ts b/src/api/routes/interactions/index.ts index 3423ed73..6c192c69 100644 --- a/src/api/routes/interactions/index.ts +++ b/src/api/routes/interactions/index.ts @@ -91,7 +91,7 @@ router.post("/", route({}), async (req: Request, res: Response) => { } if (body.type === InteractionType.MessageComponent || body.data.type === InteractionType.ModalSubmit) { - interactionData.message = await Message.findOneOrFail({ where: { id: body.message_id } }); + interactionData.message = await Message.findOneOrFail({ where: { id: body.message_id }, relations: ["author"] }); } emitEvent({ diff --git a/src/schemas/api/bots/ApplicationCommandCreateSchema.ts b/src/schemas/api/bots/ApplicationCommandCreateSchema.ts index 0217d889..a03b81cd 100644 --- a/src/schemas/api/bots/ApplicationCommandCreateSchema.ts +++ b/src/schemas/api/bots/ApplicationCommandCreateSchema.ts @@ -17,3 +17,5 @@ export interface ApplicationCommandCreateSchema { contexts?: InteractionContextType[]; handler?: ApplicationCommandHandlerType; } + +export type BulkApplicationCommandCreateSchema = ApplicationCommandCreateSchema[];