fix: socramcode

This commit is contained in:
MARCROCK22 2024-08-03 02:27:16 +00:00
parent b9abd1fa15
commit f487072ced

View File

@ -143,7 +143,7 @@ export class BaseInteraction<
return { return {
type: body.type, type: body.type,
//@ts-ignore //@ts-ignore
data: BaseInteraction.transformBodyRequest(body.data ?? {}, files, self), data: BaseInteraction.transformBody(body.data ?? {}, files, self),
}; };
} }
case InteractionResponseType.Modal: case InteractionResponseType.Modal:
@ -179,28 +179,27 @@ export class BaseInteraction<
) { ) {
const poll = (body as MessageWebhookCreateBodyRequest).poll; const poll = (body as MessageWebhookCreateBodyRequest).poll;
const allow = { const payload = {
allowed_mentions: self.options?.allowedMentions, allowed_mentions: self.options?.allowedMentions,
...body, ...body,
components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)), components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)),
embeds: body?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)), embeds: body?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)),
poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined, poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
}; };
if ('attachment' in body) { if ('attachments' in body) {
allow.attachments = payload.attachments =
body.attachments?.map((x, i) => ({ body.attachments?.map((x, i) => ({
id: i, id: i,
...resolveAttachment(x), ...resolveAttachment(x),
})) ?? undefined; })) ?? undefined;
} else if (files?.length) { } else if (files?.length) {
allow.attachments = files?.map((x, id) => ({ payload.attachments = files?.map((x, id) => ({
id, id,
filename: x.name, filename: x.name,
})) as RESTAPIAttachment[]; })) as RESTAPIAttachment[];
} }
return allow as unknown as T; return payload as T;
} }
private async matchReplied(body: ReplyInteractionBody) { private async matchReplied(body: ReplyInteractionBody) {