Merge pull request #1363 from MathMan05/fixes_commandFetch

Fix application-command-index
This commit is contained in:
Cyber 2025-10-22 19:36:30 +02:00 committed by GitHub
commit e22c5725f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,