Merge pull request #1363 from MathMan05/fixes_commandFetch
Fix application-command-index
1 files changed, 6 insertions, 6 deletions
diff --git a/src/api/routes/guilds/#guild_id/application-command-index.ts b/src/api/routes/guilds/#guild_id/application-command-index.ts
index 006264ad..6c5a5ffe 100644
--- a/src/api/routes/guilds/#guild_id/application-command-index.ts
+++ b/src/api/routes/guilds/#guild_id/application-command-index.ts
@@ -28,7 +28,8 @@ router.get("/", route({}), async (req: Request, res: Response) => {
const applications: Application[] = [];
for (const member of members) {
- applications.push(await Application.findOneOrFail({ where: { id: member.id } }));
+ const app = await Application.findOne({ where: { id: member.id } });
+ if (app) applications.push(app);
}
const applicationsSendable = [];
@@ -44,17 +45,16 @@ router.get("/", route({}), async (req: Request, res: Response) => {
});
}
- const globalApplicationCommands: ApplicationCommand[] = [];
- const guildApplicationCommands: ApplicationCommand[] = [];
+ const applicationCommands: ApplicationCommand[][] = [];
for (const application of applications) {
- globalApplicationCommands.push(await ApplicationCommand.findOneOrFail({ where: { application_id: application.id, guild_id: IsNull() } }));
- guildApplicationCommands.push(await ApplicationCommand.findOneOrFail({ where: { application_id: application.id, guild_id: req.params.guild_id } }));
+ 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 } }));
}
const applicationCommandsSendable = [];
- for (const command of [...globalApplicationCommands, ...guildApplicationCommands]) {
+ for (const command of applicationCommands.flat()) {
applicationCommandsSendable.push({
application_id: command.application_id,
description: command.description,
|