Skip to content

Adding components v2 support#1518

Open
MathMan05 wants to merge 33 commits intospacebarchat:masterfrom
MathMan05:compv2
Open

Adding components v2 support#1518
MathMan05 wants to merge 33 commits intospacebarchat:masterfrom
MathMan05:compv2

Conversation

@MathMan05
Copy link
Contributor

@MathMan05 MathMan05 commented Feb 13, 2026

This will add components v2 support.
this also increases conformity to the API to make pluralkit happy, and implements two new interaction types, allows nulls in certain spots instead of undefined's and various other fixes. it was a goal to get pluralkit working for Emma and those who wanted it.

if (!URL.canParse(media.url)) throw new HTTPError("media URL must be a URI");
const url = new URL(media.url);
if (!["http", "https", "attachment"].includes(url.protocol)) throw new HTTPError("invalid media protocol");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need some help finishing this function along with enabling the signing of the URLs where ever that happens

@MathMan05 MathMan05 marked this pull request as ready for review February 26, 2026 22:18
@MathMan05
Copy link
Contributor Author

image Pluralkit is now known to work under this.

@MathMan05
Copy link
Contributor Author

One thing we should look into is how this handles media from url sources, so there's not a tonne of duped media

@MathMan05
Copy link
Contributor Author

though, I think pk won't work in threads for obvious reasons

@MathMan05
Copy link
Contributor Author

still debugging pluralkit

});
OrmUtils.mergeDeep(user.settings || {}, body);
Member.update({ id: req.user_id, guild_id: req.params.guild_id as string }, user);
user.save();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...huh?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain what this does anymore tbh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why was it updated like that? It wasn't using the primary key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*as in the old way

Comment on lines +112 to +113
if (Object.keys(media).length > 1) throw new HTTPError("no, you can't send those");
if (!URL.canParse(media.url)) throw new HTTPError("media URL must be a URI");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??? what do these even mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unfurled media object can't have extra keys, and the url provided must be a valid uri

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make the first error more clear then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Comment on lines +71 to +75
proxy_url: this.proxy_url
? getUrlSignature(new NewUrlSignatureData({ ...data, url: this.proxy_url }))
.applyToUrl(this.proxy_url)
.toString()
: this.proxy_url,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong: this will never fall back to proxy_url as it should always be set, and it should always be signed regardless

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was some siutation where this wasn't the case and this fixed it.
and it does seem to be optional
https://docs.discord.food/resources/components#unfurled-media-item-object

Comment on lines 126 to -152
@@ -145,11 +153,9 @@ export class Message extends BaseClass {
cascade: true,
orphanedRowAction: "delete",
})
@JsonRemoveEmpty
attachments?: Attachment[];

@Column({ type: "simple-json" })
@JsonRemoveEmpty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove these...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's incorrect
https://docs.discord.food/resources/message#message-object
attachments can't be undefined nor can embeds

Comment on lines 536 to +831
@@ -586,14 +825,10 @@ export async function postHandleMessage(message: Message) {
if (data.embeds != undefined) {
data.embeds = data.embeds?.filter((embed) => embed.type === "rich");
}
const author = data.author?.toPublicUser();
const event = {
event: "MESSAGE_UPDATE",
channel_id: message.channel_id,
data: {
...data,
author,
},
data,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt this change remove inserting the author?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure it gets added earlier, but it's definatly there as plularkit would've thrown a fit about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants