mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
fix: preserve image order
This commit is contained in:
1 parent
495a830506
commit
ee5beeea45
1 file changed
+9
-3
@@ -11,6 +11,7 @@ import jsxToPngThreaded from '../blitzkrieg/jsxToPngThreaded';
|
|||||||
export default async function normalizeInteractionReturnable(
|
export default async function normalizeInteractionReturnable(
|
||||||
returnable: InteractionReturnable,
|
returnable: InteractionReturnable,
|
||||||
) {
|
) {
|
||||||
|
const images: [number, Buffer][] = [];
|
||||||
const reply: InteractionEditReplyOptions = {};
|
const reply: InteractionEditReplyOptions = {};
|
||||||
|
|
||||||
const awaitedReturnable = await returnable;
|
const awaitedReturnable = await returnable;
|
||||||
@@ -19,7 +20,7 @@ export default async function normalizeInteractionReturnable(
|
|||||||
: [awaitedReturnable];
|
: [awaitedReturnable];
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
normalizedReturnable.map(async (item) => {
|
normalizedReturnable.map(async (item, index) => {
|
||||||
if (typeof item === 'string') {
|
if (typeof item === 'string') {
|
||||||
reply.content = item;
|
reply.content = item;
|
||||||
} else if (item instanceof EmbedBuilder) {
|
} else if (item instanceof EmbedBuilder) {
|
||||||
@@ -38,11 +39,16 @@ export default async function normalizeInteractionReturnable(
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const image = await jsxToPngThreaded(item);
|
const image = await jsxToPngThreaded(item);
|
||||||
if (!reply.files) reply.files = [];
|
images.push([index, image]);
|
||||||
reply.files.push(image);
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (images.length > 0) {
|
||||||
|
images.sort(([a], [b]) => b - a);
|
||||||
|
if (!reply.files) reply.files = [];
|
||||||
|
images.forEach(([, image]) => reply.files?.push(image));
|
||||||
|
}
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user