diff --git "a/src/api/routes/applications/\043application_id/bot/index.ts" "b/src/api/routes/applications/\043application_id/bot/index.ts" index 7f5369a..47b8a72 100644 --- "a/src/api/routes/applications/\043application_id/bot/index.ts" +++ "b/src/api/routes/applications/\043application_id/bot/index.ts" @@ -39,7 +39,7 @@ }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { owner: true }, }); @@ -66,7 +66,7 @@ }, }), async (req: Request, res: Response) => { - const bot = await User.findOneOrFail({ where: { id: req.params.application_id } }); + const bot = await User.findOneOrFail({ where: { id: req.params.application_id as string } }); const owner = req.user; if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; @@ -110,7 +110,7 @@ } const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { bot: true, owner: true }, }); diff --git "a/src/api/routes/applications/\043application_id/commands/\043command_id/index.ts" "b/src/api/routes/applications/\043application_id/commands/\043command_id/index.ts" index 8e4c3ce..5501104 100644 --- "a/src/api/routes/applications/\043application_id/commands/\043command_id/index.ts" +++ "b/src/api/routes/applications/\043application_id/commands/\043command_id/index.ts" @@ -24,14 +24,14 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const command = await ApplicationCommand.findOne({ where: { application_id: req.params.application_id, id: req.params.command_id } }); + const command = await ApplicationCommand.findOne({ where: { application_id: req.params.application_id as string, id: req.params.command_id as string } }); if (!command) { res.status(404).send({ code: 404, message: "Unknown application command" }); @@ -47,14 +47,14 @@ requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, id: req.params.command_id } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, id: req.params.command_id as string } }); if (!commandExists) { res.status(404).send({ code: 404, message: "Unknown application command" }); @@ -78,7 +78,7 @@ } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -101,21 +101,21 @@ ); router.delete("/", async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, id: req.params.command_id } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, id: req.params.command_id as string } }); if (!commandExists) { res.status(404).send({ code: 404, message: "Unknown application command" }); return; } - await ApplicationCommand.delete({ application_id: req.params.application_id, id: req.params.command_id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, id: req.params.command_id as string }); res.sendStatus(204); }); diff --git "a/src/api/routes/applications/\043application_id/commands/index.ts" "b/src/api/routes/applications/\043application_id/commands/index.ts" index 91824be..a3aaec2 100644 --- "a/src/api/routes/applications/\043application_id/commands/index.ts" +++ "b/src/api/routes/applications/\043application_id/commands/index.ts" @@ -25,14 +25,14 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id } }); + const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string } }); res.send(command); }); @@ -42,7 +42,7 @@ requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); @@ -66,7 +66,7 @@ } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -83,10 +83,10 @@ version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: body.name.trim() } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, name: body.name.trim() } }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, name: body.name.trim() }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, 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); @@ -102,7 +102,7 @@ requestBody: "BulkApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); @@ -112,13 +112,13 @@ const body = req.body as ApplicationCommandCreateSchema[]; // Remove commands not present in array - const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id, guild_id: IsNull() } }); + const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string, guild_id: IsNull() } }); const commandNamesInArray = body.map((c) => c.name); const commandsNotInArray = applicationCommands.filter((c) => !commandNamesInArray.includes(c.name)); for (const command of commandsNotInArray) { - await ApplicationCommand.delete({ application_id: req.params.application_id, guild_id: IsNull(), id: command.id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, guild_id: IsNull(), id: command.id }); } for (const command of body) { @@ -137,7 +137,7 @@ } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: command.name.trim(), name_localizations: command.name_localizations, description: command.description?.trim() || "", @@ -154,10 +154,10 @@ version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: command.name.trim() } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, name: command.name.trim() } }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, name: command.name.trim() }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, 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/\043application_id/guilds/\043guild_id/commands/\043command_id/index.ts" "b/src/api/routes/applications/\043application_id/guilds/\043guild_id/commands/\043command_id/index.ts" index be2d62e..e4f847c 100644 --- "a/src/api/routes/applications/\043application_id/guilds/\043guild_id/commands/\043command_id/index.ts" +++ "b/src/api/routes/applications/\043application_id/guilds/\043guild_id/commands/\043command_id/index.ts" @@ -24,26 +24,28 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } - const command = await ApplicationCommand.findOne({ where: { application_id: req.params.application_id, id: req.params.command_id, guild_id: req.params.guild_id } }); + const command = await ApplicationCommand.findOne({ + where: { application_id: req.params.application_id as string, id: req.params.command_id as string, guild_id: req.params.guild_id as string }, + }); if (!command) { res.status(404).send({ code: 404, message: "Unknown application command" }); @@ -59,21 +61,21 @@ requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } @@ -95,7 +97,7 @@ } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -113,7 +115,7 @@ }; 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.trim() }, + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string, name: body.name.trim() }, }); if (!commandExists) { @@ -122,7 +124,7 @@ } await ApplicationCommand.update( - { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name.trim() }, + { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string, name: body.name.trim() }, commandForDb, ); res.send(commandForDb); @@ -130,33 +132,35 @@ ); router.delete("/", async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id } }); + const commandExists = await ApplicationCommand.exists({ + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string }, + }); if (!commandExists) { res.status(404).send({ code: 404, message: "Unknown application command" }); return; } - await ApplicationCommand.delete({ application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string }); res.sendStatus(204); }); diff --git "a/src/api/routes/applications/\043application_id/guilds/\043guild_id/commands/index.ts" "b/src/api/routes/applications/\043application_id/guilds/\043guild_id/commands/index.ts" index 607c846..e51a431 100644 --- "a/src/api/routes/applications/\043application_id/guilds/\043guild_id/commands/index.ts" +++ "b/src/api/routes/applications/\043application_id/guilds/\043guild_id/commands/index.ts" @@ -24,26 +24,26 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } - const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id } }); + const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string } }); res.send(command); }); @@ -53,21 +53,21 @@ requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } @@ -89,8 +89,8 @@ } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, - guild_id: req.params.guild_id, + application_id: req.params.application_id as string, + guild_id: req.params.guild_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -107,10 +107,12 @@ version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() } }); + const commandExists = await ApplicationCommand.exists({ + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, name: body.name.trim() }, + }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, 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); @@ -126,21 +128,21 @@ requestBody: "BulkApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } @@ -148,13 +150,13 @@ const body = req.body as ApplicationCommandCreateSchema[]; // Remove commands not present in array - const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id } }); + const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string } }); const commandNamesInArray = body.map((c) => c.name); const commandsNotInArray = applicationCommands.filter((c) => !commandNamesInArray.includes(c.name)); for (const command of commandsNotInArray) { - await ApplicationCommand.delete({ application_id: req.params.application_id, guild_id: req.params.guild_id, id: command.id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: command.id }); } for (const command of body) { @@ -173,8 +175,8 @@ } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, - guild_id: req.params.guild_id, + application_id: req.params.application_id as string, + guild_id: req.params.guild_id as string, name: command.name.trim(), name_localizations: command.name_localizations, description: command.description?.trim() || "", @@ -191,10 +193,12 @@ version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: command.name } }); + const commandExists = await ApplicationCommand.exists({ + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, name: command.name }, + }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: command.name }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, name: command.name }, 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/\043application_id/index.ts" "b/src/api/routes/applications/\043application_id/index.ts" index 58c0156..64fac23 100644 --- "a/src/api/routes/applications/\043application_id/index.ts" +++ "b/src/api/routes/applications/\043application_id/index.ts" @@ -39,7 +39,7 @@ }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { owner: true, bot: true }, }); if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; @@ -65,7 +65,7 @@ const body = req.body as ApplicationModifySchema; const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { owner: true, bot: true }, }); @@ -122,7 +122,7 @@ }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { bot: true, owner: true }, }); if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; diff --git "a/src/api/routes/channels/\043channel_id/attachments.ts" "b/src/api/routes/channels/\043channel_id/attachments.ts" index 0d5daa4..bf3c70f 100644 --- "a/src/api/routes/channels/\043channel_id/attachments.ts" +++ "b/src/api/routes/channels/\043channel_id/attachments.ts" @@ -40,7 +40,7 @@ }), async (req: Request, res: Response) => { const payload = req.body as UploadAttachmentRequestSchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const user = req.user; const channel = await Channel.findOneOrFail({ where: { id: channel_id } }); @@ -100,7 +100,7 @@ ); router.delete("/:cloud_attachment_url", async (req: Request, res: Response) => { - const { channel_id, cloud_attachment_url } = req.params; + const { channel_id, cloud_attachment_url } = req.params as { [key: string]: string }; const user = req.user; const channel = await Channel.findOneOrFail({ where: { id: channel_id } }); diff --git "a/src/api/routes/channels/\043channel_id/greet.ts" "b/src/api/routes/channels/\043channel_id/greet.ts" index c3eaa76..b556547 100644 --- "a/src/api/routes/channels/\043channel_id/greet.ts" +++ "b/src/api/routes/channels/\043channel_id/greet.ts" @@ -41,7 +41,7 @@ }), async (req: Request, res: Response) => { const payload = req.body as GreetRequestSchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git "a/src/api/routes/channels/\043channel_id/index.ts" "b/src/api/routes/channels/\043channel_id/index.ts" index bff5bb3..12333a7 100644 --- "a/src/api/routes/channels/\043channel_id/index.ts" +++ "b/src/api/routes/channels/\043channel_id/index.ts" @@ -37,7 +37,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -61,7 +61,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -147,7 +147,7 @@ }), async (req: Request, res: Response) => { const payload = req.body as ChannelModifySchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; if (payload.icon) payload.icon = await handleFile(`/channel-icons/${channel_id}`, payload.icon); const channel = await Channel.findOneOrFail({ diff --git "a/src/api/routes/channels/\043channel_id/invites.ts" "b/src/api/routes/channels/\043channel_id/invites.ts" index be97e44..979d080 100644 --- "a/src/api/routes/channels/\043channel_id/invites.ts" +++ "b/src/api/routes/channels/\043channel_id/invites.ts" @@ -43,7 +43,7 @@ async (req: Request, res: Response) => { const { user_id } = req; const body = req.body as InviteCreateSchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, select: { id: true, name: true, type: true, guild_id: true }, @@ -98,7 +98,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git "a/src/api/routes/channels/\043channel_id/messages/\043message_id/ack.ts" "b/src/api/routes/channels/\043channel_id/messages/\043message_id/ack.ts" index 7b9f039..8c34af5 100644 --- "a/src/api/routes/channels/\043channel_id/messages/\043message_id/ack.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/\043message_id/ack.ts" @@ -36,7 +36,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const permission = await getPermission(req.user_id, undefined, channel_id); permission.hasThrow("VIEW_CHANNEL"); diff --git "a/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" "b/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" index 7058bd3..c056912 100644 --- "a/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" @@ -67,7 +67,7 @@ }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; let body = req.body as MessageEditSchema; const message = await Message.findOneOrFail({ @@ -165,7 +165,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const body = req.body as MessageCreateSchema; const attachments: (MessageCreateAttachment | MessageCreateCloudAttachment)[] = body.attachments ?? []; @@ -261,7 +261,7 @@ }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, @@ -288,7 +288,7 @@ }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git "a/src/api/routes/channels/\043channel_id/messages/\043message_id/reactions.ts" "b/src/api/routes/channels/\043channel_id/messages/\043message_id/reactions.ts" index b21dbd3..8893806 100644 --- "a/src/api/routes/channels/\043channel_id/messages/\043message_id/reactions.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/\043message_id/reactions.ts" @@ -68,7 +68,7 @@ }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -104,8 +104,8 @@ }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; - const emoji = getEmoji(req.params.emoji); + const { message_id, channel_id } = req.params as { [key: string]: string }; + const emoji = getEmoji(req.params.emoji as string); const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, @@ -149,8 +149,8 @@ }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; - const emoji = getEmoji(req.params.emoji); + const { message_id, channel_id } = req.params as { [key: string]: string }; + const emoji = getEmoji(req.params.emoji as string); const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, @@ -186,9 +186,9 @@ }, }), async (req: Request, res: Response) => { - const { message_id, channel_id, user_id } = req.params; + const { message_id, channel_id, user_id } = req.params as { [key: string]: string }; if (user_id !== "@me") throw new HTTPError("Invalid user"); - const emoji = getEmoji(req.params.emoji); + const emoji = getEmoji(req.params.emoji as string); const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -261,10 +261,10 @@ }, }), async (req: Request, res: Response) => { - let { user_id } = req.params; - const { message_id, channel_id } = req.params; + let { user_id } = req.params as { [key: string]: string }; + const { message_id, channel_id } = req.params as { [key: string]: string }; - const emoji = getEmoji(req.params.emoji); + const emoji = getEmoji(req.params.emoji as string); const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -318,10 +318,10 @@ }, }), async (req: Request, res: Response) => { - let { user_id } = req.params; - const { message_id, channel_id } = req.params; + let { user_id } = req.params as { [key: string]: string }; + const { message_id, channel_id } = req.params as { [key: string]: string }; - const emoji = getEmoji(req.params.emoji); + const emoji = getEmoji(req.params.emoji as string); const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git "a/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" "b/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" index b70560e..2f83485 100644 --- "a/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" @@ -39,7 +39,7 @@ }), async (req: Request, res: Response) => { // TODO: check for differences with https://github.com/spacebarchat/server/pull/876/files#diff-95be9c4cdfd8ba6f67361cd40b9abc8226b35d83e2bb44bf5b4682f1d66155e9 - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const body = req.body as MessageThreadCreationSchema; const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, diff --git "a/src/api/routes/channels/\043channel_id/messages/bulk-delete.ts" "b/src/api/routes/channels/\043channel_id/messages/bulk-delete.ts" index f4645ab..8c543ad 100644 --- "a/src/api/routes/channels/\043channel_id/messages/bulk-delete.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/bulk-delete.ts" @@ -42,7 +42,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git "a/src/api/routes/channels/\043channel_id/messages/index.ts" "b/src/api/routes/channels/\043channel_id/messages/index.ts" index 110e890..74e30aa 100644 --- "a/src/api/routes/channels/\043channel_id/messages/index.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/index.ts" @@ -97,7 +97,7 @@ }, }), async (req: Request, res: Response) => { - const channel_id = req.params.channel_id; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); @@ -329,7 +329,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const body = req.body as MessageCreateSchema; const attachments: (Attachment | MessageCreateAttachment | MessageCreateCloudAttachment)[] = body.attachments ?? []; @@ -518,7 +518,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; // not really a channel id if read_state_type != CHANNEL + const { channel_id } = req.params as { [key: string]: string }; // not really a channel id if read_state_type != CHANNEL const body = req.body as AcknowledgeDeleteSchema; if (body.version != 2) return res.status(204).send(); // TODO: handle other read state types diff --git "a/src/api/routes/channels/\043channel_id/messages/pins/index.ts" "b/src/api/routes/channels/\043channel_id/messages/pins/index.ts" index 3316d15..9c6299d 100644 --- "a/src/api/routes/channels/\043channel_id/messages/pins/index.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/pins/index.ts" @@ -37,7 +37,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -122,7 +122,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -169,7 +169,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const pins = await Message.find({ where: { channel_id: channel_id, pinned_at: Not(IsNull()) }, diff --git "a/src/api/routes/channels/\043channel_id/messages/search.ts" "b/src/api/routes/channels/\043channel_id/messages/search.ts" index 1a371cc..77ec46c 100644 --- "a/src/api/routes/channels/\043channel_id/messages/search.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/search.ts" @@ -42,9 +42,9 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ - where: { guild_id: req.params.guild_id }, + where: { guild_id: req.params.guild_id as string }, select: { id: true }, }); const { diff --git "a/src/api/routes/channels/\043channel_id/permissions.ts" "b/src/api/routes/channels/\043channel_id/permissions.ts" index c03ca03..3b7e134 100644 --- "a/src/api/routes/channels/\043channel_id/permissions.ts" +++ "b/src/api/routes/channels/\043channel_id/permissions.ts" @@ -39,7 +39,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, overwrite_id } = req.params; + const { channel_id, overwrite_id } = req.params as { [key: string]: string }; const body = req.body as ChannelPermissionOverwriteSchema; const channel = await Channel.findOneOrFail({ @@ -82,7 +82,7 @@ // TODO: check permission hierarchy router.delete("/:overwrite_id", route({ permission: "MANAGE_ROLES", responses: { 204: {}, 404: {} } }), async (req: Request, res: Response) => { - const { channel_id, overwrite_id } = req.params; + const { channel_id, overwrite_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git "a/src/api/routes/channels/\043channel_id/pins.ts" "b/src/api/routes/channels/\043channel_id/pins.ts" index d94d4f3..3702167 100644 --- "a/src/api/routes/channels/\043channel_id/pins.ts" +++ "b/src/api/routes/channels/\043channel_id/pins.ts" @@ -38,7 +38,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -123,7 +123,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -170,7 +170,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const pins = await Message.find({ where: { channel_id: channel_id, pinned_at: Not(IsNull()) }, diff --git "a/src/api/routes/channels/\043channel_id/purge.ts" "b/src/api/routes/channels/\043channel_id/purge.ts" index 90f8c6d..bbfb51f 100644 --- "a/src/api/routes/channels/\043channel_id/purge.ts" +++ "b/src/api/routes/channels/\043channel_id/purge.ts" @@ -44,7 +44,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git "a/src/api/routes/channels/\043channel_id/recipients.ts" "b/src/api/routes/channels/\043channel_id/recipients.ts" index c001f84..71caa9e 100644 --- "a/src/api/routes/channels/\043channel_id/recipients.ts" +++ "b/src/api/routes/channels/\043channel_id/recipients.ts" @@ -32,7 +32,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, user_id } = req.params; + const { channel_id, user_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, relations: { recipients: true }, @@ -82,7 +82,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id, user_id } = req.params; + const { channel_id, user_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, relations: { recipients: true }, diff --git "a/src/api/routes/channels/\043channel_id/thread-members.ts" "b/src/api/routes/channels/\043channel_id/thread-members.ts" index 3e42f30..685252a 100644 --- "a/src/api/routes/channels/\043channel_id/thread-members.ts" +++ "b/src/api/routes/channels/\043channel_id/thread-members.ts" @@ -41,7 +41,7 @@ after?: Snowflake; limit?: string; }; - const { id: channel_id } = req.params; + const { id: channel_id } = req.params as { [key: string]: string }; if (limit && parseInt(limit) > 100) limit = "100"; @@ -69,7 +69,7 @@ }), async (req: Request, res: Response) => { // eslint-disable-next-line prefer-const - let { channel_id, user_id } = req.params; + let { channel_id, user_id } = req.params as { [key: string]: string }; const thread = await Channel.findOneOrFail({ where: { id: channel_id } }); if (user_id != "@me") (await thread.getUserPermissions({ user: req.user, guild: thread.guild })).hasThrow(Permissions.FLAGS.SEND_MESSAGES); @@ -126,7 +126,7 @@ }), async (req: Request, res: Response) => { // eslint-disable-next-line prefer-const - let { channel_id, user_id } = req.params; + let { channel_id, user_id } = req.params as { [key: string]: string }; const thread = await Channel.findOneOrFail({ where: { id: channel_id } }); // TODO: require thread creator for private threads @@ -181,9 +181,9 @@ async (req: Request, res: Response) => { // TODO // eslint-disable-next-line prefer-const - let { channel_id } = req.params; + let { channel_id } = req.params as { [key: string]: string }; const thread = await Channel.findOneOrFail({ where: { id: channel_id } }); - await Member.IsInGuildOrFail(req.params.user_id, thread.guild_id!); + await Member.IsInGuildOrFail(req.params.user_id as string, thread.guild_id!); // var threadMember = await ThreadMember.findOneOrFail({ where: { member_id: req.user_id, id: channel_id } }); // await emitEvent({ diff --git "a/src/api/routes/channels/\043channel_id/typing.ts" "b/src/api/routes/channels/\043channel_id/typing.ts" index b5b2cd1..d5890fc 100644 --- "a/src/api/routes/channels/\043channel_id/typing.ts" +++ "b/src/api/routes/channels/\043channel_id/typing.ts" @@ -33,7 +33,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const user_id = req.user_id; const timestamp = Math.floor(Date.now() / 1000); const channel = await Channel.findOneOrFail({ diff --git "a/src/api/routes/channels/\043channel_id/webhooks.ts" "b/src/api/routes/channels/\043channel_id/webhooks.ts" index 994bab2..23537b7 100644 --- "a/src/api/routes/channels/\043channel_id/webhooks.ts" +++ "b/src/api/routes/channels/\043channel_id/webhooks.ts" @@ -37,7 +37,7 @@ }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const webhooks = await Webhook.find({ where: { channel_id }, relations: { user: true, channel: true, source_channel: true, guild: true, source_guild: true, application: true }, @@ -69,7 +69,7 @@ }, }), async (req: Request, res: Response) => { - const channel_id = req.params.channel_id; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git "a/src/api/routes/connections/\043connection_name/authorize.ts" "b/src/api/routes/connections/\043connection_name/authorize.ts" index 1efb656..ca56bbe 100644 --- "a/src/api/routes/connections/\043connection_name/authorize.ts" +++ "b/src/api/routes/connections/\043connection_name/authorize.ts" @@ -23,7 +23,7 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const { connection_name } = req.params; + const { connection_name } = req.params as { [key: string]: string }; const connection = ConnectionStore.connections.get(connection_name); if (!connection) throw FieldErrors({ diff --git "a/src/api/routes/connections/\043connection_name/callback.ts" "b/src/api/routes/connections/\043connection_name/callback.ts" index a83882c..2f6a25a 100644 --- "a/src/api/routes/connections/\043connection_name/callback.ts" +++ "b/src/api/routes/connections/\043connection_name/callback.ts" @@ -24,7 +24,7 @@ const router = Router({ mergeParams: true }); router.post("/", route({ requestBody: "ConnectionCallbackSchema" }), async (req: Request, res: Response) => { - const { connection_name } = req.params; + const { connection_name } = req.params as { [key: string]: string }; const connection = ConnectionStore.connections.get(connection_name); if (!connection) throw FieldErrors({ diff --git "a/src/api/routes/emojis/\043emoji_id/source.ts" "b/src/api/routes/emojis/\043emoji_id/source.ts" index f5c4a83..10fdba0 100644 --- "a/src/api/routes/emojis/\043emoji_id/source.ts" +++ "b/src/api/routes/emojis/\043emoji_id/source.ts" @@ -36,7 +36,7 @@ }, }), async (req: Request, res: Response) => { - const { emoji_id } = req.params; + const { emoji_id } = req.params as { [key: string]: string }; const emoji = await Emoji.findOne({ where: { id: emoji_id } }); if (!emoji) { diff --git "a/src/api/routes/guilds/\043guild_id/application-command-index.ts" "b/src/api/routes/guilds/\043guild_id/application-command-index.ts" index 244029d..d5b8d6e 100644 --- "a/src/api/routes/guilds/\043guild_id/application-command-index.ts" +++ "b/src/api/routes/guilds/\043guild_id/application-command-index.ts" @@ -25,7 +25,7 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const members = await Member.find({ where: { guild_id: req.params.guild_id, user: { bot: true } } }); + const members = await Member.find({ where: { guild_id: req.params.guild_id as string, user: { bot: true } } }); const applications: Application[] = []; for (const member of members) { @@ -50,7 +50,7 @@ for (const application of applications) { applicationCommands.push(await ApplicationCommand.find({ where: { application_id: application.id, guild_id: IsNull() } })); - applicationCommands.push(await ApplicationCommand.find({ where: { application_id: application.id, guild_id: req.params.guild_id } })); + applicationCommands.push(await ApplicationCommand.find({ where: { application_id: application.id, guild_id: req.params.guild_id as string } })); } const applicationCommandsSendable: ApplicationCommandSchema[] = []; diff --git "a/src/api/routes/guilds/\043guild_id/auto-moderation/rules.ts" "b/src/api/routes/guilds/\043guild_id/auto-moderation/rules.ts" index 8c24651..8b56ded 100644 --- "a/src/api/routes/guilds/\043guild_id/auto-moderation/rules.ts" +++ "b/src/api/routes/guilds/\043guild_id/auto-moderation/rules.ts" @@ -38,7 +38,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const rules = await AutomodRule.find({ where: { guild_id } }); return res.json(rules); }, @@ -62,7 +62,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; if (req.user_id !== req.body.creator_id) throw new HTTPError("You can't create a rule for someone else", 403); if (guild_id !== req.body.guild_id) throw new HTTPError("You can't create a rule for another guild", 403); @@ -103,7 +103,7 @@ }, }), async (req: Request, res: Response) => { - const { rule_id } = req.params; + const { rule_id } = req.params as { [key: string]: string }; const rule = await AutomodRule.findOneOrFail({ where: { id: rule_id }, }); @@ -131,7 +131,7 @@ }, }), async (req: Request, res: Response) => { - const { rule_id } = req.params; + const { rule_id } = req.params as { [key: string]: string }; await AutomodRule.delete({ id: rule_id }); return res.status(204).send(); }, diff --git "a/src/api/routes/guilds/\043guild_id/bans.ts" "b/src/api/routes/guilds/\043guild_id/bans.ts" index 2bd28ac..6fa34d3 100644 --- "a/src/api/routes/guilds/\043guild_id/bans.ts" +++ "b/src/api/routes/guilds/\043guild_id/bans.ts" @@ -40,7 +40,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let bans = await Ban.find({ where: { guild_id: guild_id } }); const promisesToAwait: Promise[] = []; @@ -98,7 +98,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const limit = Number(req.query.limit) || 10; if (limit > 10 || limit < 1) throw new HTTPError("Limit must be between 1 and 10"); @@ -154,7 +154,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, user_id } = req.params; + const { guild_id, user_id } = req.params as { [key: string]: string }; const ban = (await Ban.findOneOrFail({ where: { guild_id: guild_id, user_id: user_id }, @@ -196,8 +196,8 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; - const banned_user_id = req.params.user_id; + const { guild_id } = req.params as { [key: string]: string }; + const banned_user_id = req.params.user_id as string; const opts = req.body as BanCreateSchema; let deleteMessagesMs = opts.delete_message_days @@ -262,7 +262,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, user_id } = req.params; + const { guild_id, user_id } = req.params as { [key: string]: string }; await Ban.findOneOrFail({ where: { guild_id: guild_id, user_id: user_id }, diff --git "a/src/api/routes/guilds/\043guild_id/bulk-ban.ts" "b/src/api/routes/guilds/\043guild_id/bulk-ban.ts" index 41e14eb..67b23ba 100644 --- "a/src/api/routes/guilds/\043guild_id/bulk-ban.ts" +++ "b/src/api/routes/guilds/\043guild_id/bulk-ban.ts" @@ -42,7 +42,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const userIds: Array = req.body.user_ids; if (!userIds) throw new HTTPError("The user_ids array is missing", 400); diff --git "a/src/api/routes/guilds/\043guild_id/channels.ts" "b/src/api/routes/guilds/\043guild_id/channels.ts" index fc374ac..57bc818 100644 --- "a/src/api/routes/guilds/\043guild_id/channels.ts" +++ "b/src/api/routes/guilds/\043guild_id/channels.ts" @@ -32,7 +32,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const channels = await Channel.find({ where: { guild_id } }); for await (const channel of channels) { @@ -63,7 +63,7 @@ }), async (req: Request, res: Response) => { // creates a new guild channel https://discord.com/developers/docs/resources/guild#create-guild-channel - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as ChannelModifySchema; const channel = await Channel.createChannel({ ...body, guild_id }, req.user_id); @@ -90,7 +90,7 @@ }), async (req: Request, res: Response) => { // changes guild channel position - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let body = req.body as ChannelReorderSchema; const guild = await Guild.findOneOrFail({ diff --git "a/src/api/routes/guilds/\043guild_id/delete.ts" "b/src/api/routes/guilds/\043guild_id/delete.ts" index 6e541da..1557c17 100644 --- "a/src/api/routes/guilds/\043guild_id/delete.ts" +++ "b/src/api/routes/guilds/\043guild_id/delete.ts" @@ -39,7 +39,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, diff --git "a/src/api/routes/guilds/\043guild_id/discovery-requirements.ts" "b/src/api/routes/guilds/\043guild_id/discovery-requirements.ts" index 2551276..d11d9d9 100644 --- "a/src/api/routes/guilds/\043guild_id/discovery-requirements.ts" +++ "b/src/api/routes/guilds/\043guild_id/discovery-requirements.ts" @@ -31,7 +31,7 @@ }, }), (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; // TODO: // Load from database // Admin control, but for now it allows anyone to be discoverable diff --git "a/src/api/routes/guilds/\043guild_id/emojis.ts" "b/src/api/routes/guilds/\043guild_id/emojis.ts" index 663ce41..1044b8a 100644 --- "a/src/api/routes/guilds/\043guild_id/emojis.ts" +++ "b/src/api/routes/guilds/\043guild_id/emojis.ts" @@ -36,7 +36,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -65,7 +65,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, emoji_id } = req.params; + const { guild_id, emoji_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -96,7 +96,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as EmojiCreateSchema; const id = Snowflake.generate(); @@ -153,7 +153,7 @@ }, }), async (req: Request, res: Response) => { - const { emoji_id, guild_id } = req.params; + const { emoji_id, guild_id } = req.params as { [key: string]: string }; const body = req.body as EmojiModifySchema; if (body.name?.includes("-")) body.name = body.name?.replaceAll("-", ""); // Dashes are invalid apparently @@ -189,7 +189,7 @@ }, }), async (req: Request, res: Response) => { - const { emoji_id, guild_id } = req.params; + const { emoji_id, guild_id } = req.params as { [key: string]: string }; await Emoji.delete({ id: emoji_id, diff --git "a/src/api/routes/guilds/\043guild_id/index.ts" "b/src/api/routes/guilds/\043guild_id/index.ts" index 8bb9e7d..2bfa9c8 100644 --- "a/src/api/routes/guilds/\043guild_id/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/index.ts" @@ -40,7 +40,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const [guild, member] = await Promise.all([Guild.findOneOrFail({ where: { id: guild_id } }), Member.findOne({ where: { guild_id: guild_id, id: req.user_id } })]); if (!member) throw new HTTPError("You are not a member of the guild you are trying to access", 401); @@ -74,7 +74,7 @@ }), async (req: Request, res: Response) => { const body = req.body as GuildUpdateSchema; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const rights = await getRights(req.user_id); const permission = await getPermission(req.user_id, guild_id); diff --git "a/src/api/routes/guilds/\043guild_id/invites.ts" "b/src/api/routes/guilds/\043guild_id/invites.ts" index 32d86a4..656d06d 100644 --- "a/src/api/routes/guilds/\043guild_id/invites.ts" +++ "b/src/api/routes/guilds/\043guild_id/invites.ts" @@ -33,7 +33,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const invites = await Invite.find({ where: { guild_id }, diff --git "a/src/api/routes/guilds/\043guild_id/members/\043member_id/index.ts" "b/src/api/routes/guilds/\043guild_id/members/\043member_id/index.ts" index 7049857..2ccece6 100644 --- "a/src/api/routes/guilds/\043guild_id/members/\043member_id/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/members/\043member_id/index.ts" @@ -39,7 +39,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, member_id } = req.params; + const { guild_id, member_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); const member = await Member.findOneOrFail({ @@ -85,8 +85,8 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; - const member_id = req.params.member_id === "@me" ? req.user_id : req.params.member_id; + const { guild_id } = req.params as { [key: string]: string }; + const member_id = req.params.member_id === "@me" ? req.user_id : (req.params.member_id as string); const body = req.body as MemberChangeSchema; const member = await Member.findOneOrFail({ @@ -168,8 +168,8 @@ const rights = await getRights(req.user_id); - const { guild_id } = req.params; - let { member_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; + let { member_id } = req.params as { [key: string]: string }; if (member_id === "@me") { member_id = req.user_id; rights.hasThrow("JOIN_GUILDS"); @@ -216,7 +216,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, member_id } = req.params; + const { guild_id, member_id } = req.params as { [key: string]: string }; const permission = await getPermission(req.user_id, guild_id); const rights = await getRights(req.user_id); if (member_id === "@me" || member_id === req.user_id) { diff --git "a/src/api/routes/guilds/\043guild_id/members/\043member_id/nick.ts" "b/src/api/routes/guilds/\043guild_id/members/\043member_id/nick.ts" index 87c95aa..0e6a746 100644 --- "a/src/api/routes/guilds/\043guild_id/members/\043member_id/nick.ts" +++ "b/src/api/routes/guilds/\043guild_id/members/\043member_id/nick.ts" @@ -39,9 +39,9 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let permissionString: PermissionResolvable = "MANAGE_NICKNAMES"; - const member_id = req.params.member_id === "@me" ? ((permissionString = "CHANGE_NICKNAME"), req.user_id) : req.params.member_id; + const member_id = req.params.member_id === "@me" ? ((permissionString = "CHANGE_NICKNAME"), req.user_id) : (req.params.member_id as string); const perms = await getPermission(req.user_id, guild_id); perms.hasThrow(permissionString); diff --git "a/src/api/routes/guilds/\043guild_id/members/\043member_id/roles/\043role_id/index.ts" "b/src/api/routes/guilds/\043guild_id/members/\043member_id/roles/\043role_id/index.ts" index d482c06..ccfc37b 100644 --- "a/src/api/routes/guilds/\043guild_id/members/\043member_id/roles/\043role_id/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/members/\043member_id/roles/\043role_id/index.ts" @@ -34,7 +34,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, role_id, member_id } = req.params; + const { guild_id, role_id, member_id } = req.params as { [key: string]: string }; await Member.removeRole(member_id, guild_id, role_id); res.sendStatus(204); @@ -51,7 +51,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, role_id, member_id } = req.params; + const { guild_id, role_id, member_id } = req.params as { [key: string]: string }; await Member.addRole(member_id, guild_id, role_id); res.sendStatus(204); diff --git "a/src/api/routes/guilds/\043guild_id/members/index.ts" "b/src/api/routes/guilds/\043guild_id/members/index.ts" index 08b7707..78a35d8 100644 --- "a/src/api/routes/guilds/\043guild_id/members/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/members/index.ts" @@ -50,7 +50,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const limit = Number(req.query.limit) || 1; if (limit > 1000 || limit < 1) throw new HTTPError("Limit must be between 1 and 1000"); const after = `${req.query.after}`; diff --git "a/src/api/routes/guilds/\043guild_id/messages/search.ts" "b/src/api/routes/guilds/\043guild_id/messages/search.ts" index 51c9b5a..166b87e 100644 --- "a/src/api/routes/guilds/\043guild_id/messages/search.ts" +++ "b/src/api/routes/guilds/\043guild_id/messages/search.ts" @@ -66,7 +66,7 @@ }); // todo this is wrong } - const permissions = await getPermission(req.user_id, req.params.guild_id, channel_id as string | undefined); + const permissions = await getPermission(req.user_id, req.params.guild_id as string, channel_id as string | undefined); permissions.hasThrow("VIEW_CHANNEL"); if (!permissions.has("READ_MESSAGE_HISTORY")) return res.json({ messages: [], total_results: 0 }); @@ -77,7 +77,7 @@ take: parsedLimit || 0, where: { guild: { - id: req.params.guild_id, + id: req.params.guild_id as string, }, }, relations: { author: true, webhook: true, application: true, mentions: true, mention_roles: true, mention_channels: true, sticker_items: true, attachments: true }, @@ -88,13 +88,13 @@ else { // get all channel IDs that this user can access const channels = await Channel.find({ - where: { guild_id: req.params.guild_id }, + where: { guild_id: req.params.guild_id as string }, select: { id: true }, }); const ids = []; for (const channel of channels) { - const perm = await getPermission(req.user_id, req.params.guild_id, channel.id); + const perm = await getPermission(req.user_id, req.params.guild_id as string, channel.id); if (!perm.has("VIEW_CHANNEL") || !perm.has("READ_MESSAGE_HISTORY")) continue; ids.push(channel.id); } diff --git "a/src/api/routes/guilds/\043guild_id/profile.ts" "b/src/api/routes/guilds/\043guild_id/profile.ts" index 176c612..8bbdce1 100644 --- "a/src/api/routes/guilds/\043guild_id/profile.ts" +++ "b/src/api/routes/guilds/\043guild_id/profile.ts" @@ -33,7 +33,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); const profileResponse: GuildProfileResponse = { id: guild_id, diff --git "a/src/api/routes/guilds/\043guild_id/profile/index.ts" "b/src/api/routes/guilds/\043guild_id/profile/index.ts" index b7a071b..0e35aac 100644 --- "a/src/api/routes/guilds/\043guild_id/profile/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/profile/index.ts" @@ -40,7 +40,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; // const member_id = // req.params.member_id === "@me" ? req.user_id : req.params.member_id; const body = req.body as MemberChangeProfileSchema; diff --git "a/src/api/routes/guilds/\043guild_id/prune.ts" "b/src/api/routes/guilds/\043guild_id/prune.ts" index 7179147..e2504bf 100644 --- "a/src/api/routes/guilds/\043guild_id/prune.ts" +++ "b/src/api/routes/guilds/\043guild_id/prune.ts" @@ -87,7 +87,7 @@ let roles = req.query.include_roles; if (typeof roles === "string") roles = [roles]; //express will return array otherwise - const members = await inactiveMembers(req.params.guild_id, req.user_id, days, roles as string[]); + const members = await inactiveMembers(req.params.guild_id as string, req.user_id, days, roles as string[]); res.send({ pruned: members.length }); }, @@ -113,7 +113,7 @@ let roles = req.query.include_roles; if (typeof roles === "string") roles = [roles]; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const members = await inactiveMembers(guild_id, req.user_id, days, roles as string[]); await Promise.all(members.map((x) => Member.removeFromGuild(x.id, guild_id))); diff --git "a/src/api/routes/guilds/\043guild_id/regions.ts" "b/src/api/routes/guilds/\043guild_id/regions.ts" index b2a311d..66c1e68 100644 --- "a/src/api/routes/guilds/\043guild_id/regions.ts" +++ "b/src/api/routes/guilds/\043guild_id/regions.ts" @@ -35,7 +35,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); //TODO we should use an enum for guild's features and not hardcoded strings return res.json(await getVoiceRegions(req.ip!, guild.features.includes("VIP_REGIONS"))); diff --git "a/src/api/routes/guilds/\043guild_id/roles/\043role_id/index.ts" "b/src/api/routes/guilds/\043guild_id/roles/\043role_id/index.ts" index 1811284..af2d3a3 100644 --- "a/src/api/routes/guilds/\043guild_id/roles/\043role_id/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/roles/\043role_id/index.ts" @@ -40,7 +40,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); const role = await Role.findOneOrFail({ where: { guild_id, id: role_id }, @@ -67,7 +67,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; if (role_id === guild_id) throw new HTTPError("You can't delete the @everyone role"); await Promise.all([ @@ -112,7 +112,7 @@ }, }), async (req: Request, res: Response) => { - const { role_id, guild_id } = req.params; + const { role_id, guild_id } = req.params as { [key: string]: string }; const body = req.body as RoleModifySchema; if (body.icon && body.icon.length) body.icon = await handleFile(`/role-icons/${role_id}`, body.icon as string); diff --git "a/src/api/routes/guilds/\043guild_id/roles/\043role_id/member-ids.ts" "b/src/api/routes/guilds/\043guild_id/roles/\043role_id/member-ids.ts" index e4dccb3..afa8d18 100644 --- "a/src/api/routes/guilds/\043guild_id/roles/\043role_id/member-ids.ts" +++ "b/src/api/routes/guilds/\043guild_id/roles/\043role_id/member-ids.ts" @@ -23,7 +23,7 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; // TODO: Is this route really not paginated? const members = await Member.find({ diff --git "a/src/api/routes/guilds/\043guild_id/roles/\043role_id/members.ts" "b/src/api/routes/guilds/\043guild_id/roles/\043role_id/members.ts" index 6eb6804..aea54b1 100644 --- "a/src/api/routes/guilds/\043guild_id/roles/\043role_id/members.ts" +++ "b/src/api/routes/guilds/\043guild_id/roles/\043role_id/members.ts" @@ -24,7 +24,7 @@ router.patch("/", route({ permission: "MANAGE_ROLES" }), async (req: Request, res: Response) => { // Payload is JSON containing a list of member_ids, the new list of members to have the role - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; const { member_ids } = req.body; // don't mess with @everyone diff --git "a/src/api/routes/guilds/\043guild_id/roles/index.ts" "b/src/api/routes/guilds/\043guild_id/roles/index.ts" index 8caea56..b8e2b1a 100644 --- "a/src/api/routes/guilds/\043guild_id/roles/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/roles/index.ts" @@ -25,7 +25,7 @@ const router: Router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -52,7 +52,7 @@ }, }), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; const body = req.body as RoleModifySchema; const role_count = await Role.count({ where: { guild_id } }); @@ -124,7 +124,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as RolePositionUpdateSchema; await Promise.all(body.map(async (x) => Role.update({ guild_id, id: x.id }, { position: x.position }))); diff --git "a/src/api/routes/guilds/\043guild_id/roles/member-counts.ts" "b/src/api/routes/guilds/\043guild_id/roles/member-counts.ts" index 0f3a12c..59783c3 100644 --- "a/src/api/routes/guilds/\043guild_id/roles/member-counts.ts" +++ "b/src/api/routes/guilds/\043guild_id/roles/member-counts.ts" @@ -23,7 +23,7 @@ const router: Router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); const role_ids = await Role.find({ where: { guild_id }, select: { id: true } }); diff --git "a/src/api/routes/guilds/\043guild_id/shield.svg.ts" "b/src/api/routes/guilds/\043guild_id/shield.svg.ts" index aaf7bce..bb5e1c7 100644 --- "a/src/api/routes/guilds/\043guild_id/shield.svg.ts" +++ "b/src/api/routes/guilds/\043guild_id/shield.svg.ts" @@ -51,7 +51,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let cacheEntry = jsonDataCache.get(guild_id); if (!cacheEntry || cacheEntry.expiry.getTime() < Date.now()) { diff --git "a/src/api/routes/guilds/\043guild_id/stickers.ts" "b/src/api/routes/guilds/\043guild_id/stickers.ts" index dd1498e..857713d 100644 --- "a/src/api/routes/guilds/\043guild_id/stickers.ts" +++ "b/src/api/routes/guilds/\043guild_id/stickers.ts" @@ -37,7 +37,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); res.json(await Sticker.find({ where: { guild_id } })); @@ -74,7 +74,7 @@ async (req: Request, res: Response) => { if (!req.file) throw new HTTPError("missing file"); - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as ModifyGuildStickerSchema; const id = Snowflake.generate(); @@ -132,7 +132,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, sticker_id } = req.params; + const { guild_id, sticker_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); res.json( @@ -161,7 +161,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, sticker_id } = req.params; + const { guild_id, sticker_id } = req.params as { [key: string]: string }; const body = req.body as ModifyGuildStickerSchema; const sticker = await Sticker.create({ @@ -198,7 +198,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id, sticker_id } = req.params; + const { guild_id, sticker_id } = req.params as { [key: string]: string }; await Sticker.delete({ guild_id, id: sticker_id }); await sendStickerUpdateEvent(guild_id); diff --git "a/src/api/routes/guilds/\043guild_id/templates.ts" "b/src/api/routes/guilds/\043guild_id/templates.ts" index e577cea..54b7fce 100644 --- "a/src/api/routes/guilds/\043guild_id/templates.ts" +++ "b/src/api/routes/guilds/\043guild_id/templates.ts" @@ -51,7 +51,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const templates = await Template.find({ where: { source_guild_id: guild_id }, @@ -82,7 +82,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: TemplateGuildProjection, @@ -117,7 +117,7 @@ }, }), async (req: Request, res: Response) => { - const { code, guild_id } = req.params; + const { code, guild_id } = req.params as { [key: string]: string }; const template = await Template.delete({ code, @@ -138,7 +138,7 @@ }, }), async (req: Request, res: Response) => { - const { code, guild_id } = req.params; + const { code, guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: TemplateGuildProjection, @@ -164,7 +164,7 @@ }, }), async (req: Request, res: Response) => { - const { code, guild_id } = req.params; + const { code, guild_id } = req.params as { [key: string]: string }; const { name, description } = req.body; const template = await Template.findOneOrFail({ diff --git "a/src/api/routes/guilds/\043guild_id/vanity-url.ts" "b/src/api/routes/guilds/\043guild_id/vanity-url.ts" index e622c25..ec3f0ab 100644 --- "a/src/api/routes/guilds/\043guild_id/vanity-url.ts" +++ "b/src/api/routes/guilds/\043guild_id/vanity-url.ts" @@ -43,7 +43,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); if (!guild.features.includes("ALIASABLE_NAMES")) { @@ -82,7 +82,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as VanityUrlSchema; const code = body.code?.replace(InviteRegex, ""); diff --git "a/src/api/routes/guilds/\043guild_id/voice-states/\043user_id/index.ts" "b/src/api/routes/guilds/\043guild_id/voice-states/\043user_id/index.ts" index 5283ae0..95c3928 100644 --- "a/src/api/routes/guilds/\043guild_id/voice-states/\043user_id/index.ts" +++ "b/src/api/routes/guilds/\043guild_id/voice-states/\043user_id/index.ts" @@ -43,8 +43,8 @@ }), async (req: Request, res: Response) => { const body = req.body as VoiceStateUpdateSchema; - const { guild_id } = req.params; - const user_id = req.params.user_id === "@me" ? req.user_id : req.params.user_id; + const { guild_id } = req.params as { [key: string]: string }; + const user_id = req.params.user_id === "@me" ? req.user_id : (req.params.user_id as string); const perms = await getPermission(req.user_id, guild_id, body.channel_id); diff --git "a/src/api/routes/guilds/\043guild_id/webhooks.ts" "b/src/api/routes/guilds/\043guild_id/webhooks.ts" index 65fa0ab..cb717f9 100644 --- "a/src/api/routes/guilds/\043guild_id/webhooks.ts" +++ "b/src/api/routes/guilds/\043guild_id/webhooks.ts" @@ -33,7 +33,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const webhooks = await Webhook.find({ where: { guild_id }, relations: { user: true, channel: true, source_channel: true, guild: true, source_guild: true, application: true }, diff --git "a/src/api/routes/guilds/\043guild_id/welcome-screen.ts" "b/src/api/routes/guilds/\043guild_id/welcome-screen.ts" index 474d597..dee7fb4 100644 --- "a/src/api/routes/guilds/\043guild_id/welcome-screen.ts" +++ "b/src/api/routes/guilds/\043guild_id/welcome-screen.ts" @@ -36,7 +36,7 @@ }, }), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -61,7 +61,7 @@ }, }), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; const body = req.body as GuildUpdateWelcomeScreenSchema; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); diff --git "a/src/api/routes/guilds/\043guild_id/widget.json.ts" "b/src/api/routes/guilds/\043guild_id/widget.json.ts" index 6827c7f..945a0db 100644 --- "a/src/api/routes/guilds/\043guild_id/widget.json.ts" +++ "b/src/api/routes/guilds/\043guild_id/widget.json.ts" @@ -47,7 +47,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let cacheEntry = jsonDataCache.get(guild_id); if (!cacheEntry || cacheEntry.expiry.getTime() < Date.now()) { diff --git "a/src/api/routes/guilds/\043guild_id/widget.png.ts" "b/src/api/routes/guilds/\043guild_id/widget.png.ts" index 3ff95e9..c1382c9 100644 --- "a/src/api/routes/guilds/\043guild_id/widget.png.ts" +++ "b/src/api/routes/guilds/\043guild_id/widget.png.ts" @@ -46,7 +46,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); if (!guild.widget_enabled) throw DiscordApiErrors.EMBED_DISABLED; diff --git "a/src/api/routes/guilds/\043guild_id/widget.ts" "b/src/api/routes/guilds/\043guild_id/widget.ts" index 5a2fdb9..122789d 100644 --- "a/src/api/routes/guilds/\043guild_id/widget.ts" +++ "b/src/api/routes/guilds/\043guild_id/widget.ts" @@ -37,7 +37,7 @@ }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); @@ -68,7 +68,7 @@ }), async (req: Request, res: Response) => { const body = req.body as WidgetModifySchema; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Guild.update( { id: guild_id }, diff --git a/src/api/routes/guilds/templates/index.ts b/src/api/routes/guilds/templates/index.ts index 51d2fd3..391f9c8 100644 --- a/src/api/routes/guilds/templates/index.ts +++ b/src/api/routes/guilds/templates/index.ts @@ -40,7 +40,7 @@ }, }), async (req: Request, res: Response) => { - const { template_code } = req.params; + const { template_code } = req.params as { [key: string]: string }; const template = await getTemplate(template_code); @@ -49,7 +49,7 @@ ); router.post("/:template_code", route({ requestBody: "GuildTemplateCreateSchema" }), async (req: Request, res: Response) => { - const { template_code } = req.params; + const { template_code } = req.params as { [key: string]: string }; const body = req.body as GuildTemplateCreateSchema; const { maxGuilds } = Config.get().limits.user; diff --git "a/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" "b/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" index e94d455..3734a12 100644 --- "a/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" +++ "b/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" @@ -68,7 +68,7 @@ throw FieldErrors(errors); } - const interactionId = req.params.interaction_id; + const interactionId = req.params.interaction_id as string; const interaction = pendingInteractions.get(req.params.interaction_id); if (!interaction) { diff --git a/src/api/routes/invites/index.ts b/src/api/routes/invites/index.ts index 630fe03..316e768 100644 --- a/src/api/routes/invites/index.ts +++ b/src/api/routes/invites/index.ts @@ -37,7 +37,7 @@ }, }), async (req: Request, res: Response) => { - const { invite_code } = req.params; + const { invite_code } = req.params as { [key: string]: string }; const invite = await Invite.findOneOrFail({ where: { code: invite_code }, @@ -70,7 +70,7 @@ async (req: Request, res: Response) => { if (req.user_bot && !Config.get().user.botsCanUseInvites) throw DiscordApiErrors.BOT_PROHIBITED_ENDPOINT; - const { invite_code } = req.params; + const { invite_code } = req.params as { [key: string]: string }; const { public_flags } = req.user; const { guild_id } = await Invite.findOneOrFail({ where: { code: invite_code }, @@ -128,7 +128,7 @@ }, }), async (req: Request, res: Response) => { - const { invite_code } = req.params; + const { invite_code } = req.params as { [key: string]: string }; const invite = await Invite.findOneOrFail({ where: { code: invite_code } }); const { guild_id, channel_id } = invite; diff --git a/src/api/routes/oauth2/applications/@me.ts b/src/api/routes/oauth2/applications/@me.ts index e750a62..c8aa84f 100644 --- a/src/api/routes/oauth2/applications/@me.ts +++ b/src/api/routes/oauth2/applications/@me.ts @@ -34,7 +34,7 @@ }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.id }, // ...huh? there's no ID in the path... + where: { id: req.params.id as string }, // ...huh? there's no ID in the path... relations: { bot: true, owner: true }, select: { owner: Object.fromEntries(PublicUserProjection.map((x) => [x, true])), diff --git "a/src/api/routes/partners/\043guild_id/requirements.ts" "b/src/api/routes/partners/\043guild_id/requirements.ts" index 3f0e48c..7592d23 100644 --- "a/src/api/routes/partners/\043guild_id/requirements.ts" +++ "b/src/api/routes/partners/\043guild_id/requirements.ts" @@ -22,7 +22,7 @@ const router = Router({ mergeParams: true }); router.get("/", route({}), (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; // TODO: // Load from database // Admin control, but for now it allows anyone to be discoverable diff --git "a/src/api/routes/stickers/\043sticker_id/index.ts" "b/src/api/routes/stickers/\043sticker_id/index.ts" index 0f850ef..ddfbbe4 100644 --- "a/src/api/routes/stickers/\043sticker_id/index.ts" +++ "b/src/api/routes/stickers/\043sticker_id/index.ts" @@ -31,7 +31,7 @@ }, }), async (req: Request, res: Response) => { - const { sticker_id } = req.params; + const { sticker_id } = req.params as { [key: string]: string }; res.json(await Sticker.find({ where: { id: sticker_id } })); }, diff --git "a/src/api/routes/store/published-listings/skus/\043sku_id/subscription-plans.ts" "b/src/api/routes/store/published-listings/skus/\043sku_id/subscription-plans.ts" index 2c9ad4e..13db49d 100644 --- "a/src/api/routes/store/published-listings/skus/\043sku_id/subscription-plans.ts" +++ "b/src/api/routes/store/published-listings/skus/\043sku_id/subscription-plans.ts" @@ -318,7 +318,7 @@ router.get("/", route({}), (req: Request, res: Response) => { // TODO: add the ability to add custom - const { sku_id } = req.params; + const { sku_id } = req.params as { [key: string]: string }; if (!skus.has(sku_id)) { console.log(`Request for invalid SKU ${sku_id}! Please report this!`); diff --git "a/src/api/routes/users/\043user_id/delete.ts" "b/src/api/routes/users/\043user_id/delete.ts" index 598be97..a0730cb 100644 --- "a/src/api/routes/users/\043user_id/delete.ts" +++ "b/src/api/routes/users/\043user_id/delete.ts" @@ -58,7 +58,7 @@ const sw = Stopwatch.startNew(); const body = req.body as InstanceUserDeleteSchema | undefined; const user = await User.findOneOrFail({ - where: { id: req.params.user_id }, + where: { id: req.params.user_id as string }, select: [...PrivateUserProjection, "data"], }); @@ -130,11 +130,11 @@ ); // change ownership on guilds - const guilds = await Guild.find({ where: { owner_id: req.params.user_id } }); + const guilds = await Guild.find({ where: { owner_id: req.params.user_id as string } }); await Promise.all( guilds.map(async (guild) => { const members = await Member.find({ - where: { guild_id: guild.id, id: Not(req.params.user_id) }, + where: { guild_id: guild.id, id: Not(req.params.user_id as string) }, relations: { roles: true }, select: { id: true, roles: { id: true, position: true } }, }); @@ -156,7 +156,7 @@ console.log(`[Instance ban] Transferred ownership of guild ${guild.id} to user ${guild.owner_id}`); // safety - reassign emojis/stickers owned by the old owner - const stickers = await Sticker.find({ where: { guild_id: guild.id, user_id: req.params.user_id } }); + const stickers = await Sticker.find({ where: { guild_id: guild.id, user_id: req.params.user_id as string } }); await Promise.all( stickers.map(async (sticker) => { sticker.user_id = guild.owner_id; @@ -165,7 +165,7 @@ }), ); - const emojis = await Emoji.find({ where: { guild_id: guild.id, user_id: req.params.user_id } }); + const emojis = await Emoji.find({ where: { guild_id: guild.id, user_id: req.params.user_id as string } }); await Promise.all( emojis.map(async (emoji) => { emoji.user_id = guild.owner_id!; @@ -177,16 +177,16 @@ }), ); - const members = await Member.find({ where: { id: req.params.user_id } }); + const members = await Member.find({ where: { id: req.params.user_id as string } }); await Promise.all([...members.map((member) => Member.removeFromGuild(member.id, member.guild_id))]); - await UserSettingsProtos.delete({ user_id: req.params.user_id }); - await User.delete({ id: req.params.user_id }); + await UserSettingsProtos.delete({ user_id: req.params.user_id as string }); + await User.delete({ id: req.params.user_id as string }); // TODO: respect intents as USER_DELETE has potential to cause privacy issues await emitEvent({ event: "USER_DELETE", user_id: req.user_id, - data: { user_id: req.params.user_id }, + data: { user_id: req.params.user_id as string }, } as UserDeleteEvent); console.log(`[Instance ban] Deleted user ${user.id} from instance in ${sw.elapsed().toString()}`); diff --git "a/src/api/routes/users/\043user_id/index.ts" "b/src/api/routes/users/\043user_id/index.ts" index 7fca1e0..ada0e91 100644 --- "a/src/api/routes/users/\043user_id/index.ts" +++ "b/src/api/routes/users/\043user_id/index.ts" @@ -32,7 +32,7 @@ }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; res.json(await User.getPublicUser(user_id)); }, diff --git "a/src/api/routes/users/\043user_id/messages.ts" "b/src/api/routes/users/\043user_id/messages.ts" index 95c7cfc..5d86c28 100644 --- "a/src/api/routes/users/\043user_id/messages.ts" +++ "b/src/api/routes/users/\043user_id/messages.ts" @@ -35,7 +35,7 @@ }, }), async (req: Request, res: Response) => { - const user = await User.findOneOrFail({ where: { id: req.params.user_id } }); + const user = await User.findOneOrFail({ where: { id: req.params.user_id as string } }); const channel = await user.getDmChannelWith(req.user_id); const messages = ( diff --git "a/src/api/routes/users/\043user_id/profile.ts" "b/src/api/routes/users/\043user_id/profile.ts" index c7996c0..fccdeca 100644 --- "a/src/api/routes/users/\043user_id/profile.ts" +++ "b/src/api/routes/users/\043user_id/profile.ts" @@ -28,7 +28,7 @@ if (req.params.user_id === "@me") req.params.user_id = req.user_id; const { guild_id, with_mutual_guilds, with_mutual_friends, with_mutual_friends_count } = req.query; - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; const user = await User.findOneOrFail({ where: { diff --git "a/src/api/routes/users/\043user_id/relationships.ts" "b/src/api/routes/users/\043user_id/relationships.ts" index 93f1129..38bd64b 100644 --- "a/src/api/routes/users/\043user_id/relationships.ts" +++ "b/src/api/routes/users/\043user_id/relationships.ts" @@ -37,7 +37,7 @@ const mutual_relations: UserRelationsResponse = []; const requested_relations = await User.findOneOrFail({ - where: { id: req.params.user_id }, + where: { id: req.params.user_id as string }, relations: { relationships: true }, }); const self_relations = await User.findOneOrFail({ diff --git "a/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/access-token.ts" "b/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/access-token.ts" index a85348a..6e6d7e2 100644 --- "a/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/access-token.ts" +++ "b/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/access-token.ts" @@ -28,7 +28,7 @@ // NOTE: this route has not been extensively tested, as the required connections are not implemented as of writing router.get("/", route({}), async (req: Request, res: Response) => { - const { connection_name, connection_id } = req.params; + const { connection_name, connection_id } = req.params as { [key: string]: string }; const connection = ConnectionStore.connections.get(connection_name); diff --git "a/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/index.ts" "b/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/index.ts" index 718c80c..0fc6f3f 100644 --- "a/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/index.ts" +++ "b/src/api/routes/users/@me/connections/\043connection_name/\043connection_id/index.ts" @@ -24,7 +24,7 @@ // TODO: connection update schema router.patch("/", route({ requestBody: "ConnectionUpdateSchema" }), async (req: Request, res: Response) => { - const { connection_name, connection_id } = req.params; + const { connection_name, connection_id } = req.params as { [key: string]: string }; const body = req.body as ConnectionUpdateSchema; const connection = await ConnectedAccount.findOne({ @@ -63,7 +63,7 @@ }); router.delete("/", route({}), async (req: Request, res: Response) => { - const { connection_name, connection_id } = req.params; + const { connection_name, connection_id } = req.params as { [key: string]: string }; const account = await ConnectedAccount.findOneOrFail({ where: { diff --git a/src/api/routes/users/@me/guilds.ts b/src/api/routes/users/@me/guilds.ts index 8fcec95..d274067 100644 --- a/src/api/routes/users/@me/guilds.ts +++ b/src/api/routes/users/@me/guilds.ts @@ -64,7 +64,7 @@ }), async (req: Request, res: Response) => { const { autoJoin } = Config.get().guild; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: { owner_id: true }, diff --git "a/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" "b/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" index 3aaf723..1501ac4 100644 --- "a/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" +++ "b/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" @@ -34,7 +34,7 @@ }), async (req: Request, res: Response) => { const user = await Member.findOneOrFail({ - where: { id: req.user_id, guild_id: req.params.guild_id }, + where: { id: req.user_id, guild_id: req.params.guild_id as string }, select: { settings: true }, }); return res.json(user.settings); @@ -65,11 +65,11 @@ } const user = await Member.findOneOrFail({ - where: { id: req.user_id, guild_id: req.params.guild_id }, + where: { id: req.user_id, guild_id: req.params.guild_id as string }, select: { settings: true }, }); OrmUtils.mergeDeep(user.settings || {}, body); - Member.update({ id: req.user_id, guild_id: req.params.guild_id }, user); + Member.update({ id: req.user_id, guild_id: req.params.guild_id as string }, user); res.json(user.settings); }, diff --git "a/src/api/routes/users/@me/mfa/webauthn/credentials/\043key_id/index.ts" "b/src/api/routes/users/@me/mfa/webauthn/credentials/\043key_id/index.ts" index 77180ca..65c0180 100644 --- "a/src/api/routes/users/@me/mfa/webauthn/credentials/\043key_id/index.ts" +++ "b/src/api/routes/users/@me/mfa/webauthn/credentials/\043key_id/index.ts" @@ -29,7 +29,7 @@ }, }), async (req: Request, res: Response) => { - const { key_id } = req.params; + const { key_id } = req.params as { [key: string]: string }; await SecurityKey.delete({ id: key_id, diff --git a/src/api/routes/users/@me/notes.ts b/src/api/routes/users/@me/notes.ts index f25aca7..0b17479 100644 --- a/src/api/routes/users/@me/notes.ts +++ b/src/api/routes/users/@me/notes.ts @@ -35,7 +35,7 @@ }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; const note = await Note.findOneOrFail({ where: { @@ -64,7 +64,7 @@ }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; const owner = req.user; const target = await User.findOneOrFail({ where: { id: user_id } }); //if noted user does not exist throw const { note } = req.body; diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts index 37d5e22..88f95a3 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts @@ -69,7 +69,7 @@ req, res, await User.findOneOrFail({ - where: { id: req.params.user_id }, + where: { id: req.params.user_id as string }, relations: { relationships: { to: true } }, select: userProjection, }), @@ -97,7 +97,7 @@ const rel = await Relationship.findOneOrFail({ where: { from_id: req.user_id, - to_id: req.params.user_id, + to_id: req.params.user_id as string, }, }); rel.nickname = body.nickname; @@ -161,7 +161,7 @@ }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; if (user_id === req.user_id) throw new HTTPError("You can't remove yourself as a friend"); const user = await User.findOneOrFail({ diff --git "a/src/api/routes/webhooks/\043webhook_id/\043token/index.ts" "b/src/api/routes/webhooks/\043webhook_id/\043token/index.ts" index 7bb1cd9..556ee48 100644 --- "a/src/api/routes/webhooks/\043webhook_id/\043token/index.ts" +++ "b/src/api/routes/webhooks/\043webhook_id/\043token/index.ts" @@ -19,7 +19,7 @@ }, }), async (req: Request, res: Response) => { - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const webhook = await Webhook.findOne({ where: { id: webhook_id, @@ -101,7 +101,7 @@ }, }), async (req: Request, res: Response) => { - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const webhook = await Webhook.findOne({ where: { @@ -149,7 +149,7 @@ }, }), async (req: Request, res: Response) => { - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const body = req.body as WebhookUpdateSchema; const webhook = await Webhook.findOneOrFail({ diff --git "a/src/api/routes/webhooks/\043webhook_id/index.ts" "b/src/api/routes/webhooks/\043webhook_id/index.ts" index bf275fb..2282a46 100644 --- "a/src/api/routes/webhooks/\043webhook_id/index.ts" +++ "b/src/api/routes/webhooks/\043webhook_id/index.ts" @@ -17,7 +17,7 @@ }, }), async (req: Request, res: Response) => { - const { webhook_id } = req.params; + const { webhook_id } = req.params as { [key: string]: string }; const webhook = await Webhook.findOneOrFail({ where: { id: webhook_id }, relations: { user: true, channel: true, source_channel: true, guild: true, source_guild: true, application: true }, @@ -48,7 +48,7 @@ }, }), async (req: Request, res: Response) => { - const { webhook_id } = req.params; + const { webhook_id } = req.params as { [key: string]: string }; const webhook = await Webhook.findOneOrFail({ where: { id: webhook_id }, @@ -93,7 +93,7 @@ }, }), async (req: Request, res: Response) => { - const { webhook_id } = req.params; + const { webhook_id } = req.params as { [key: string]: string }; const body = req.body as WebhookUpdateSchema; const webhook = await Webhook.findOneOrFail({ diff --git a/src/api/util/handlers/Webhook.ts b/src/api/util/handlers/Webhook.ts index d4aceb8..fe14417 100644 --- a/src/api/util/handlers/Webhook.ts +++ b/src/api/util/handlers/Webhook.ts @@ -8,7 +8,7 @@ export const executeWebhook = async (req: Request, res: Response) => { const body = req.body as WebhookExecuteSchema; - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const webhook = await Webhook.findOne({ where: { diff --git a/src/api/util/handlers/route.ts b/src/api/util/handlers/route.ts index 022a522..43aab15 100644 --- a/src/api/util/handlers/route.ts +++ b/src/api/util/handlers/route.ts @@ -89,7 +89,8 @@ return async (req: Request, res: Response, next: NextFunction) => { if (opts.permission) { - req.permission = await getPermission(req.user_id, req.params.guild_id, req.params.channel_id); + const { guild_id, channel_id } = req.params as { [key: string]: string }; + req.permission = await getPermission(req.user_id, guild_id, channel_id); const requiredPerms = Array.isArray(opts.permission) ? opts.permission : [opts.permission]; requiredPerms.forEach((perm) => { diff --git a/src/cdn/routes/attachments.ts b/src/cdn/routes/attachments.ts index 2bbf39b..86a7f0c 100644 --- a/src/cdn/routes/attachments.ts +++ b/src/cdn/routes/attachments.ts @@ -36,7 +36,7 @@ if (!req.file) throw new HTTPError("file missing"); const { buffer, mimetype, size, originalname } = req.file; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const filename = originalname.replaceAll(" ", "_").replace(/[^a-zA-Z0-9._]+/g, ""); const id = Snowflake.generate(); const path = `attachments/${channel_id}/${id}/${filename}`; @@ -71,7 +71,7 @@ }); router.get("/:channel_id/:id/:filename", cache, async (req: Request, res: Response) => { - const { channel_id, id, filename } = req.params; + const { channel_id, id, filename } = req.params as { [key: string]: string }; // const { format } = req.query; const path = `attachments/${channel_id}/${id}/${filename}`; @@ -108,7 +108,7 @@ router.delete("/:channel_id/:id/:filename", async (req: Request, res: Response) => { if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); - const { channel_id, id, filename } = req.params; + const { channel_id, id, filename } = req.params as { [key: string]: string }; const path = `attachments/${channel_id}/${id}/${filename}`; await storage.delete(path); @@ -118,7 +118,7 @@ // "cloud attachments" router.put("/:channel_id/:batch_id/:attachment_id/:filename", multer.single("file"), async (req: Request, res: Response) => { - const { channel_id, batch_id, attachment_id, filename } = req.params; + const { channel_id, batch_id, attachment_id, filename } = req.params as { [key: string]: string }; const att = await CloudAttachment.findOneOrFail({ where: { uploadFilename: `${channel_id}/${batch_id}/${attachment_id}/${filename}`, @@ -177,7 +177,7 @@ if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); console.log("[Cloud Delete] Deleting attachment", req.params); - const { channel_id, batch_id, attachment_id, filename } = req.params; + const { channel_id, batch_id, attachment_id, filename } = req.params as { [key: string]: string }; const path = `attachments/${channel_id}/${batch_id}/${attachment_id}/${filename}`; const att = await CloudAttachment.findOne({ @@ -201,7 +201,7 @@ if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); console.log("[Cloud Clone] Cloning attachment to message", req.params); - const { channel_id, batch_id, attachment_id, filename, message_id } = req.params; + const { channel_id, batch_id, attachment_id, filename, message_id } = req.params as { [key: string]: string }; const path = `attachments/${channel_id}/${batch_id}/${attachment_id}/${filename}`; const newPath = `attachments/${channel_id}/${message_id}/${filename}`; diff --git a/src/cdn/routes/avatars.ts b/src/cdn/routes/avatars.ts index f2aae62..793bc45 100644 --- a/src/cdn/routes/avatars.ts +++ b/src/cdn/routes/avatars.ts @@ -40,7 +40,7 @@ if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); if (!req.file) throw new HTTPError("Missing file"); const { buffer, size } = req.file; - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); @@ -62,7 +62,7 @@ }); router.get("/:user_id", cache, async (req: Request, res: Response) => { - let { user_id } = req.params; + let { user_id } = req.params as { [key: string]: string }; user_id = user_id.split(".")[0]; // remove .file extension const path = `avatars/${user_id}`; @@ -76,8 +76,8 @@ }); export const getAvatar = async (req: Request, res: Response) => { - const { user_id } = req.params; - let { hash } = req.params; + const { user_id } = req.params as { [key: string]: string }; + let { hash } = req.params as { [key: string]: string }; hash = hash.split(".")[0]; // remove .file extension const path = `avatars/${user_id}/${hash}`; @@ -94,7 +94,7 @@ router.delete("/:user_id/:id", async (req: Request, res: Response) => { if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); - const { user_id, id } = req.params; + const { user_id, id } = req.params as { [key: string]: string }; const path = `avatars/${user_id}/${id}`; await storage.delete(path); diff --git a/src/cdn/routes/badge-icons.ts b/src/cdn/routes/badge-icons.ts index 2d202d0..829baeb 100644 --- a/src/cdn/routes/badge-icons.ts +++ b/src/cdn/routes/badge-icons.ts @@ -25,7 +25,7 @@ const router = Router({ mergeParams: true }); router.get("/:badge_id", cache, async (req: Request, res: Response) => { - const { badge_id } = req.params; + const { badge_id } = req.params as { [key: string]: string }; const path = `badge-icons/${badge_id}`; const file = await storage.get(path); diff --git a/src/cdn/routes/embed.ts b/src/cdn/routes/embed.ts index bc76438..463279a 100644 --- a/src/cdn/routes/embed.ts +++ b/src/cdn/routes/embed.ts @@ -60,7 +60,7 @@ } router.get("/avatars/:id", cache, async (req: Request, res: Response) => { - let { id } = req.params; + let { id } = req.params as { [key: string]: string }; id = id.split(".")[0]; // remove .file extension const hash = defaultAvatarHashMap.get(id); if (!hash) throw new HTTPError("not found", 404); @@ -76,7 +76,7 @@ }); router.get("/group-avatars/:id", cache, async (req: Request, res: Response) => { - let { id } = req.params; + let { id } = req.params as { [key: string]: string }; id = id.split(".")[0]; // remove .file extension const hash = defaultGroupDMAvatarHashMap.get(id); if (!hash) throw new HTTPError("not found", 404); diff --git a/src/cdn/routes/guild-profiles.ts b/src/cdn/routes/guild-profiles.ts index f605ad7..279b436 100644 --- a/src/cdn/routes/guild-profiles.ts +++ b/src/cdn/routes/guild-profiles.ts @@ -40,7 +40,7 @@ if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); if (!req.file) throw new HTTPError("Missing file"); const { buffer, size } = req.file; - const { guild_id, user_id } = req.params; + const { guild_id, user_id } = req.params as { [key: string]: string }; let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); @@ -62,8 +62,8 @@ }); router.get("/", cache, async (req: Request, res: Response) => { - const { guild_id } = req.params; - let { user_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; + let { user_id } = req.params as { [key: string]: string }; user_id = user_id.split(".")[0]; // remove .file extension const path = `guilds/${guild_id}/users/${user_id}/avatars`; @@ -77,8 +77,8 @@ }); router.get("/:hash", cache, async (req: Request, res: Response) => { - const { guild_id, user_id } = req.params; - let { hash } = req.params; + const { guild_id, user_id } = req.params as { [key: string]: string }; + let { hash } = req.params as { [key: string]: string }; hash = hash.split(".")[0]; // remove .file extension const path = `guilds/${guild_id}/users/${user_id}/avatars/${hash}`; @@ -93,7 +93,7 @@ router.delete("/:id", async (req: Request, res: Response) => { if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); - const { guild_id, user_id, id } = req.params; + const { guild_id, user_id, id } = req.params as { [key: string]: string }; const path = `guilds/${guild_id}/users/${user_id}/avatars/${id}`; await storage.delete(path); diff --git a/src/cdn/routes/role-icons.ts b/src/cdn/routes/role-icons.ts index 1f0c5b9..2aaa619 100644 --- a/src/cdn/routes/role-icons.ts +++ b/src/cdn/routes/role-icons.ts @@ -40,7 +40,7 @@ if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); if (!req.file) throw new HTTPError("Missing file"); const { buffer, size } = req.file; - const { role_id } = req.params; + const { role_id } = req.params as { [key: string]: string }; const hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); @@ -61,7 +61,7 @@ }); router.get("/:role_id", cache, async (req: Request, res: Response) => { - const { role_id } = req.params; + const { role_id } = req.params as { [key: string]: string }; //role_id = role_id.split(".")[0]; // remove .file extension const path = `role-icons/${role_id}`; @@ -75,7 +75,7 @@ }); router.get("/:role_id/:hash", cache, async (req: Request, res: Response) => { - const { role_id, hash } = req.params; + const { role_id, hash } = req.params as { [key: string]: string }; //hash = hash.split(".")[0]; // remove .file extension const requested_extension = hash.split(".")[1]; const role_icon_hash = hash.split(".")[0]; @@ -98,7 +98,7 @@ router.delete("/:role_id/:id", async (req: Request, res: Response) => { if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); - const { role_id, id } = req.params; + const { role_id, id } = req.params as { [key: string]: string }; const path = `role-icons/${role_id}/${id}`; await storage.delete(path); diff --git a/src/cdn/util/basicCrdFileRouter.ts b/src/cdn/util/basicCrdFileRouter.ts index 46fcf88..d489f37 100644 --- a/src/cdn/util/basicCrdFileRouter.ts +++ b/src/cdn/util/basicCrdFileRouter.ts @@ -49,7 +49,7 @@ if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); if (!req.file) throw new HTTPError("Missing file"); const { buffer, size } = req.file; - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); @@ -71,7 +71,7 @@ }); router.get("/:user_id", async (req: Request, res: Response) => { - let { user_id } = req.params; + let { user_id } = req.params as { [key: string]: string }; user_id = user_id.split(".")[0]; // remove .file extension const path = `${opts.pathPrefix}/${user_id}`; @@ -86,8 +86,8 @@ }); const getAvatar = async (req: Request, res: Response) => { - const { user_id } = req.params; - let { hash } = req.params; + const { user_id } = req.params as { [key: string]: string }; + let { hash } = req.params as { [key: string]: string }; hash = hash.split(".")[0]; // remove .file extension const path = `${opts.pathPrefix}/${user_id}/${hash}`; @@ -105,7 +105,7 @@ router.delete("/:user_id/:hash", async (req: Request, res: Response) => { if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); - const { user_id, hash } = req.params; + const { user_id, hash } = req.params as { [key: string]: string }; const path = `${opts.pathPrefix}/${user_id}/${hash}`; await storage.delete(path);