Revert "fix: no sense it doing it twice when it could be done in one query"
This commit is contained in:
parent
3718418516
commit
542c9c6e82
@ -19,6 +19,7 @@
|
||||
import { route } from "@spacebar/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Application, ApplicationCommand, Member, Snowflake } from "@spacebar/util";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
|
||||
@ -30,7 +31,6 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
applications.push(await Application.findOneOrFail({ where: { id: member.id } }));
|
||||
}
|
||||
|
||||
const applicationCommands: ApplicationCommand[] = [];
|
||||
const applicationsSendable = [];
|
||||
|
||||
for (const application of applications) {
|
||||
@ -42,13 +42,19 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
id: application.id,
|
||||
name: application.name,
|
||||
});
|
||||
}
|
||||
|
||||
applicationCommands.push(await ApplicationCommand.findOneOrFail({ where: { application_id: application.id } }));
|
||||
const globalApplicationCommands: ApplicationCommand[] = [];
|
||||
const guildApplicationCommands: 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 } }));
|
||||
}
|
||||
|
||||
const applicationCommandsSendable = [];
|
||||
|
||||
for (const command of applicationCommands) {
|
||||
for (const command of [...globalApplicationCommands, ...guildApplicationCommands]) {
|
||||
applicationCommandsSendable.push({
|
||||
application_id: command.application_id,
|
||||
description: command.description,
|
||||
|
||||
Reference in New Issue
Block a user