Skip to content

Dev/emma/as to satisfies gw#1585

Merged
TheArcaneBrony merged 37 commits intomasterfrom
dev/emma/as-to-satisfies-gw
Mar 21, 2026
Merged

Dev/emma/as to satisfies gw#1585
TheArcaneBrony merged 37 commits intomasterfrom
dev/emma/as-to-satisfies-gw

Conversation

@TheArcaneBrony
Copy link
Member

pushing the messages one soon

@TheArcaneBrony TheArcaneBrony linked an issue Mar 10, 2026 that may be closed by this pull request
@oh64
Copy link
Contributor

oh64 commented Mar 10, 2026

I realize that the openapi.json is not correct at all

@TheArcaneBrony
Copy link
Member Author

never has been

@oh64
Copy link
Contributor

oh64 commented Mar 11, 2026

channel_id,
message_id,
version: 3763,
version: 3763, // what is this number?
Copy link
Contributor

Choose a reason for hiding this comment

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

it's the user read state version apparently
https://docs.discord.food/gateway/gateway-events#message-ack

...new_message.toJSON(),
nonce: undefined,
},
} satisfies MessageUpdateEvent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this no longer promise.all?

Copy link
Member Author

Choose a reason for hiding this comment

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

this just avoids a case where saving the message fails for some reason, otherwise it'd still get sent to clients but then dissapear upon reload

delete message.member;

await message.save();
const publicMsg = message.toJSON();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this isn't being done inline?

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, i guess i could have?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine either way for me, but you've in the past have said that single use stuff like this might better be inlined

mention_everyone: false,
});

await message.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

can this not be added to the Promise.all?

Copy link
Member Author

Choose a reason for hiding this comment

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

prevents db invalid messages from being emitted


message.pinned_at = null;

await message.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, why not in the Promise.all?

Copy link
Member Author

Choose a reason for hiding this comment

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

see others


channel.last_message_id = message.id;

await message.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason for not being in the Promise.all?

Copy link
Member Author

Choose a reason for hiding this comment

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

see others

mention_everyone: false,
});

await message.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

why not in the Promise.all?

Copy link
Member Author

Choose a reason for hiding this comment

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

see others


message.pinned_at = null;

await message.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not in the Promise.all?

Copy link
Member Author

Choose a reason for hiding this comment

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

see others

guild_id: thread.guild_id!,
id: thread.id,
member_count: thread.member_count,
member_count: thread.member_count ?? 0, //TODO: is this the right fix?
Copy link
Contributor

Choose a reason for hiding this comment

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

That is fine

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

parse: body.message.allowed_mentions.parse as ("users" | "roles" | "everyone")[],
}
: undefined,
} as Parameters<typeof handleMessage>[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

could satisfies be used here?

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, im not sure if it can be, i think the entire point was to have type suggestions there but satisfies might conflict with futher handling (might make more sense to add right below, though, since it is using the first param of handleMessage as type)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wait, this is an array of strings and you're narrowing it, right?

data: {
id: interactionId,
nonce: interaction?.nonce,
nonce: interaction.nonce ?? "", // TODO: did i do this right?
Copy link
Contributor

Choose a reason for hiding this comment

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

it likely does not matter either way

Copy link
Member Author

Choose a reason for hiding this comment

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

alright, will remove the comment then

data: {
channel_id,
guild_id: webhook.guild_id,
guild_id: webhook.guild_id!, // TODO: is this even the right fix?
Copy link
Contributor

Choose a reason for hiding this comment

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

fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

as in, is this even correct? cause im asserting that guild_id isnt null (why can that even be null?)

parse: body.allowed_mentions.parse as ("users" | "roles" | "everyone")[],
}
: undefined,
} as Parameters<typeof handleMessage>[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

could satifies be used instead?


import { WebSocket } from "@spacebar/gateway";
import { emitEvent, PresenceUpdateEvent, PrivateSessionProjection, Session, SessionsReplace, User, VoiceState, VoiceStateUpdateEvent } from "@spacebar/util";
import member_id from "../../api/routes/guilds/#guild_id/members/#member_id";
Copy link
Contributor

Choose a reason for hiding this comment

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

what's up with this weird import?

Copy link
Member Author

Choose a reason for hiding this comment

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

good question, guessing it was automatically inserted

}

// TODO: split up by channel type?
export interface PublicChannel {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this not be in schemas?

Copy link
Member Author

Choose a reason for hiding this comment

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

it... is? lol

};
}

export interface PublicMessage {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this not be in schemas?

Copy link
Member Author

Choose a reason for hiding this comment

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

it... is, lol - check the path again


export enum MessageActivityType {
JOIN = 1,
// @deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

While it is deprecated on the API should it be marked as a depricated part of the enum, that'll mean we'll get warns when we try to implement it

Copy link
Member Author

Choose a reason for hiding this comment

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

i was mirroring the deprecation from discord.food here

mentions: this.mentions?.map((user) => {
if (user && !user.toPublicUser) console.trace("toPublic user missing!!!");
return user?.toPublicUser?.() ?? user ?? undefined;
return (user?.toPublicUser?.() ?? user ?? undefined) as unknown as PartialUser;
Copy link
Contributor

Choose a reason for hiding this comment

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

Might filter it out afterwards instead of doing this

Copy link
Member Author

Choose a reason for hiding this comment

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

hm?

Copy link
Contributor

Choose a reason for hiding this comment

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

as PartialUser|undefined).filter(=>!==undefined)

Copy link
Contributor

@MathMan05 MathMan05 left a comment

Choose a reason for hiding this comment

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

for those of which I clicked the wrong button

TheArcaneBrony and others added 28 commits March 20, 2026 18:16
@TheArcaneBrony TheArcaneBrony force-pushed the dev/emma/as-to-satisfies-gw branch from d483ca4 to 7a92946 Compare March 21, 2026 07:28
@TheArcaneBrony TheArcaneBrony merged commit 7a92946 into master Mar 21, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants