mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
fix: embeds (#215)
This commit is contained in:
parent
ad5edad727
commit
ddc6dab0db
@ -133,26 +133,10 @@ export class BaseInteraction<
|
||||
return body;
|
||||
case InteractionResponseType.ChannelMessageWithSource:
|
||||
case InteractionResponseType.UpdateMessage: {
|
||||
const poll = (body as InteractionCreateBodyRequest).poll;
|
||||
return {
|
||||
type: body.type,
|
||||
//@ts-ignore
|
||||
data: {
|
||||
//@ts-ignore
|
||||
allowed_mentions: self.options?.allowedMentions,
|
||||
...(body.data ?? {}),
|
||||
//@ts-ignore
|
||||
components: body.data?.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)),
|
||||
embeds: body.data?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)),
|
||||
attachments:
|
||||
body.data && 'attachments' in body.data
|
||||
? body.data.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) }))
|
||||
: (files?.map((x, id) => ({
|
||||
id,
|
||||
filename: x.name,
|
||||
})) as RESTAPIAttachment[]),
|
||||
poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
|
||||
},
|
||||
data: BaseInteraction.transformBodyRequest(body.data ?? {}, files, self),
|
||||
};
|
||||
}
|
||||
case InteractionResponseType.Modal:
|
||||
@ -188,20 +172,28 @@ export class BaseInteraction<
|
||||
) {
|
||||
const poll = (body as MessageWebhookCreateBodyRequest).poll;
|
||||
|
||||
return {
|
||||
const allow = {
|
||||
allowed_mentions: self.options?.allowedMentions,
|
||||
attachments:
|
||||
'attachments' in body
|
||||
? body.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) }))
|
||||
: (files?.map((x, id) => ({
|
||||
id,
|
||||
filename: x.name,
|
||||
})) as RESTAPIAttachment[]),
|
||||
|
||||
...body,
|
||||
components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)),
|
||||
embeds: body?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)),
|
||||
poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
|
||||
} as T;
|
||||
};
|
||||
|
||||
if ('attachment' in body) {
|
||||
allow.attachments =
|
||||
body.attachments?.map((x, i) => ({
|
||||
id: i,
|
||||
...resolveAttachment(x),
|
||||
})) ?? undefined;
|
||||
} else if (files?.length) {
|
||||
allow.attachments = files?.map((x, id) => ({
|
||||
id,
|
||||
filename: x.name,
|
||||
})) as RESTAPIAttachment[];
|
||||
}
|
||||
return allow as unknown as T;
|
||||
}
|
||||
|
||||
private async matchReplied(body: ReplyInteractionBody) {
|
||||
|
@ -280,23 +280,27 @@ export class MessagesMethods extends DiscordBase {
|
||||
self: UsingClient,
|
||||
) {
|
||||
const poll = (body as MessageCreateBodyRequest).poll;
|
||||
return {
|
||||
const allow = {
|
||||
allowed_mentions: self.options?.allowedMentions,
|
||||
...body,
|
||||
components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined,
|
||||
embeds: body.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)) ?? undefined,
|
||||
attachments:
|
||||
'attachments' in body
|
||||
? body.attachments?.map((x, i) => ({
|
||||
id: i,
|
||||
...resolveAttachment(x),
|
||||
})) ?? undefined
|
||||
: (files?.map((x, id) => ({
|
||||
id,
|
||||
filename: x.name,
|
||||
})) as RESTAPIAttachment[]),
|
||||
poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
|
||||
} as T;
|
||||
};
|
||||
|
||||
if ('attachment' in body) {
|
||||
allow.attachments =
|
||||
body.attachments?.map((x, i) => ({
|
||||
id: i,
|
||||
...resolveAttachment(x),
|
||||
})) ?? undefined;
|
||||
} else if (files?.length) {
|
||||
allow.attachments = files?.map((x, id) => ({
|
||||
id,
|
||||
filename: x.name,
|
||||
})) as RESTAPIAttachment[];
|
||||
}
|
||||
return allow as unknown as T;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user