spacebarchat / server

Spacebar server - A reimplementation of the Discord.com backend, built with Typescript and love
https://spacebar.chat
GNU Affero General Public License v3.0
1.48k stars 251 forks source link

Message Creation: Inconsistency between Discord and Spacebar #1050

Open bitfl0wer opened 1 year ago

bitfl0wer commented 1 year ago

Screenshot of Discord API Docs Screenshot of Spacebar API Docs Two small things:

That's all :)

bitfl0wer commented 1 year ago

Relevant URLs: Discord Docs: Message creation Spacebar API Docs: POST /channels/{channel_id}/messages/

Puyodead1 commented 1 year ago

I thought this was a legacy thing but I can't find anything about it in the discord docs history so idk.

MaddyUnderStars commented 1 year ago

I'm pretty sure the discord.com client does send message type in this endpoint, but the default type is just a normal message which is used when it's undef.

Edit: newer clients may or may not, I haven't checked.

bitfl0wer commented 1 year ago

I'm pretty sure the discord.com client does send message type in this endpoint, but the default type is just a normal message which is used when it's undef.

Edit: newer clients may or may not, I haven't checked.

grafik It would seem that they don't: This is the request body for sending a message via the official Web Client

MaddyUnderStars commented 1 year ago

https://github.com/spacebarchat/server/blob/master/src/api/routes/channels/%23channel_id/messages/index.ts#L299-L309 https://github.com/spacebarchat/server/blob/master/src/util/schemas/MessageCreateSchema.ts#L26-L27

it's optional in our impl, so I guess it's fine. Weird that the docs don't display that, though. I suppose if it's not sent ever, we could remove it, but I still think it is sent at some point. Perhaps for message references ( type is set to reply ). Idk

Puyodead1 commented 1 year ago

https://github.com/spacebarchat/server/blob/master/src/api/routes/channels/%23channel_id/messages/index.ts#L299-L309 https://github.com/spacebarchat/server/blob/master/src/util/schemas/MessageCreateSchema.ts#L26-L27

it's optional in our impl, so I guess it's fine. Weird that the docs don't display that, though. I suppose if it's not sent ever, we could remove it, but I still think it is sent at some point. Perhaps for message references ( type is set to reply ). Idk

nah, its just message_reference, that is used to make it a reply.

Puyodead1 commented 1 year ago

is that showing the post fields only or the entire Message schema?

TheArcaneBrony commented 6 months ago

Theory: doesn't newer versions of the Discord API express message type via flags?

kozabrada123 commented 6 months ago

It seems that embed is a deprecated field (in favor of embeds), which is why it isn't documented in the discord docs

Screenshot 2024-05-12 at 09-50-29 Discord Userdoccers - Unofficial API Documentation (source)

Also, the message type is included in the message object, but not in the create message parameters. Looks like the message type is inferred server side, used for more than just usual "messages" (CALL, RECIPIENT_ADD, USER_JOIN, etc. used for other endpoints / actions; REPLY created by sending message_reference in create message)

kozabrada123 commented 6 months ago

Theory: doesn't newer versions of the Discord API express message type via flags?

Screenshot 2024-05-12 at 10-56-36 Discord Userdoccers - Unofficial API Documentation

Screenshot 2024-05-12 at 10-56-12 Discord Userdoccers - Unofficial API Documentation

Seems like flags are a whole separate thing, they are sent along with the type in a full message object and by themselves when creating a message